Route read-only API workloads with Read Scale-Out

Completed

Read Scale-Out separates suitable analytical reads from the primary database workload. Business Central can route a read-only connection to a secondary database replica when the environment supports that capability.

Identify a suitable read-only workload

Use read-only intent for a request that can complete without inserting, modifying, or deleting data. Common candidates include analytical API queries, export feeds, historical reporting, and synchronization requests that tolerate a small delay.

Avoid read-only intent when the request:

  • Performs or depends on a write.
  • Must immediately observe a preceding write.
  • Runs business logic that modifies records indirectly.
  • Requires primary-database consistency for a decision.

A secondary replica receives changes asynchronously from the primary database. The result can lag behind a recently committed write. This behavior makes Read Scale-Out unsuitable for a create-and-read sequence that assumes read-your-own-write consistency.

Apply data access intent

Set DataAccessIntent = ReadOnly on an API query or on a noneditable API page.

query 71301 "Customer Snapshot API"
{
    QueryType = API;
    DataAccessIntent = ReadOnly;
    APIPublisher = 'training';
    APIGroup = 'integration';
    APIVersion = 'v1.0';
    EntityName = 'customerSnapshot';
    EntitySetName = 'customerSnapshots';

    elements
    {
        dataitem(Customer; Customer)
        {
            column(id; SystemId) { }
            column(number; "No.") { }
            column(displayName; Name) { }
        }
    }
}

For an API page, set Editable = false when DataAccessIntent = ReadOnly. A modification attempt on a read-only connection causes a runtime error.

An API consumer can send the Data-Access-Intent request header with ReadOnly or ReadWrite. The header overrides the object's property unless an administrator has configured a higher-precedence override on the Database Access Intent List page.

GET {endpoint}?$select=id,number,displayName&$top=25
Authorization: Bearer {token}
Data-Access-Intent: ReadOnly

Modification requests such as POST, PATCH, PUT, and DELETE support only ReadWrite. Don't send Data-Access-Intent: ReadOnly with a write request.

Interpret routing evidence correctly

ReadOnly is a declaration of intent. It allows the server to use a read-only connection and a replica when one is available, but it doesn't prove that a specific request ran on a replica.

Environment behavior matters:

  • Business Central online production: Read Scale-Out is available and enabled on the database platform.
  • Business Central online sandbox: Objects compile and run with DataAccessIntent, but the sandbox accesses the primary database.
  • Business Central on-premises: The database and Business Central Server require Read Scale-Out configuration.

Validate the workload before comparing performance. Use the same filters, selected columns, paging, and representative data volume. Compare request duration and resource evidence across multiple runs rather than relying on one response. A faster response alone doesn't prove replica routing because caching and workload variation also affect duration.

Document the following conclusions:

  • Why the workload is safe without write access.
  • Whether a propagation delay is acceptable.
  • Which object property, request header, or administrator override supplies the intent.
  • Which environment can provide routing evidence.
  • Which fallback behavior applies when no replica is available.

For platform constraints and environment behavior, see Use read scale-out for better performance and DataAccessIntent property.