> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic Production Topology

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

When you're ready to run CockroachDB in production in a single region, it's important to deploy at least 3 CockroachDB nodes to take advantage of CockroachDB's automatic replication, distribution, rebalancing, and resiliency capabilities.

<Tip>
  If you haven't already, <InternalLink path="topology-patterns">review the full range of topology patterns</InternalLink> to ensure you choose the right one for your use case.
</Tip>

## Before you begin

* Multi-region topology patterns are almost always table-specific. If you haven't already, <InternalLink path="topology-patterns#multi-region">review the full range of patterns</InternalLink> to ensure you choose the right one for each of your tables.
* Review how data is replicated and distributed across a cluster, and how this affects performance. It is especially important to understand the concept of the "leaseholder". For a summary, see <InternalLink path="architecture/reads-and-writes-overview">Reads and Writes in CockroachDB</InternalLink>. For a deeper dive, see the CockroachDB <InternalLink path="architecture/overview">Architecture Overview</InternalLink>.
* Review the concept of <InternalLink path="cockroach-start#locality">locality</InternalLink>, which CockroachDB uses to place and balance data based on how you define <InternalLink path="configure-replication-zones">replication controls</InternalLink>.
* Review the recommendations and requirements in our <InternalLink path="recommended-production-settings">Production Checklist</InternalLink>.
* This topology doesn't account for hardware specifications, so be sure to follow our <InternalLink path="recommended-production-settings#hardware">hardware recommendations</InternalLink> and perform a POC to size hardware for your use case. For optimal cluster performance, Cockroach Labs recommends that all nodes use the same hardware and operating system.
* Adopt relevant <InternalLink path="performance-best-practices-overview">SQL Best Practices</InternalLink> to ensure optimal performance.

## Configuration

<img src="https://mintcdn.com/cockroachlabs/V8OBdqIJgvCqrzhu/images/v25.2/topology-patterns/topology_basic_production1.png?fit=max&auto=format&n=V8OBdqIJgvCqrzhu&q=85&s=86de743611264ec63775e6a62cd53152" alt="Basic production topology" width="960" height="540" data-path="images/v25.2/topology-patterns/topology_basic_production1.png" />

1. Provision hardware as follows:
   * 1 region with 3 AZs
   * 3+ VMs evenly distributed across AZs; add more VMs to increase throughput
   * App and load balancer in same region as VMs for CockroachDB
     * The load balancer redirects to CockroachDB nodes in the region
2. Start each node on a separate VM, setting the <InternalLink path="cockroach-start#locality">`--locality`</InternalLink> flag to the node's region and AZ combination. For example, the following command starts a node in the east1 availability zone of the us-east region:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach start \
   --locality=region=us-east,zone=east1 \
   --certs-dir=certs \
   --advertise-addr=<node1 internal address \
   --join=<node1 internal address:26257,<node2 internal address:26257,<node3 internal address:26257 \
   --cache=.25 \
   --max-sql-memory=.25
   ```

With the default 3-way replication factor and `--locality` set as described, CockroachDB balances each range of table data across AZs, one replica per AZ. System data is replicated 5 times by default and also balanced across AZs, thus increasing the <InternalLink path="configure-replication-zones#create-a-replication-zone-for-a-system-range">resiliency of the cluster</InternalLink> as a whole.

## Characteristics

### Latency

#### Reads

Since all ranges, including leaseholder replicas, are in a single region, read latency is very low.

For example, in the animation below:

1. The read request reaches the load balancer.
2. The load balancer routes the request to a gateway node.
3. The gateway node routes the request to the relevant leaseholder.
4. The leaseholder retrieves the results and returns to the gateway node.
5. The gateway node returns the results to the client.

<img src="https://mintcdn.com/cockroachlabs/V8OBdqIJgvCqrzhu/images/v25.2/topology-patterns/topology_basic_production_reads.png?fit=max&auto=format&n=V8OBdqIJgvCqrzhu&q=85&s=5b801c615be3cfde4336a1b46df271a0" alt="Basic production topology reads" width="960" height="540" data-path="images/v25.2/topology-patterns/topology_basic_production_reads.png" />

#### Writes

Since all ranges are in a single region, writes achieve consensus without leaving the region and, thus, write latency is very low as well.

For example, in the animation below:

1. The write request reaches the load balancer.
2. The load balancer routes the request to a gateway node.
3. The gateway node routes the request to the leaseholder replicas for the relevant table and secondary index.
4. While each leaseholder appends the write to its Raft log, it notifies its follower replicas.
5. In each case, as soon as one follower has appended the write to its Raft log (and thus a majority of replicas agree based on identical Raft logs), it notifies the leaseholder and the write is committed on the agreeing replicas.
6. The leaseholders then return acknowledgement of the commit to the gateway node.
7. The gateway node returns the acknowledgement to the client.

<img src="https://mintcdn.com/cockroachlabs/RcaRllbndDZ1GfVd/images/v25.2/topology-patterns/topology_basic_production_writes.gif?s=4d9e51a6f26a0a6ee4a5180bab50e288" alt="Leaseholder preferences topology writes" width="960" height="540" data-path="images/v25.2/topology-patterns/topology_basic_production_writes.gif" />

### Resiliency

Because each range is balanced across AZs, one AZ can fail without interrupting access to any data:

<img src="https://mintcdn.com/cockroachlabs/RcaRllbndDZ1GfVd/images/v25.2/topology-patterns/topology_basic_production_resiliency1.png?fit=max&auto=format&n=RcaRllbndDZ1GfVd&q=85&s=b57db77ee785a6da769cc87f9acccad4" alt="Basic production topology single zone failure" width="960" height="540" data-path="images/v25.2/topology-patterns/topology_basic_production_resiliency1.png" />

However, if an additional AZ fails at the same time, the ranges that lose consensus become unavailable for reads and writes:

<img src="https://mintcdn.com/cockroachlabs/RcaRllbndDZ1GfVd/images/v25.2/topology-patterns/topology_basic_production_resiliency2.png?fit=max&auto=format&n=RcaRllbndDZ1GfVd&q=85&s=6f57efef8e7efec6cd86b73a054965a5" alt="Basic production topology double zone failure" width="960" height="540" data-path="images/v25.2/topology-patterns/topology_basic_production_resiliency2.png" />

## See also

* <InternalLink path="multiregion-overview">Multi-Region Capabilities Overview</InternalLink>
* <InternalLink path="choosing-a-multi-region-configuration">How to Choose a Multi-Region Configuration</InternalLink>
* <InternalLink path="multiregion-survival-goals#when-to-use-zone-vs-region-survival-goals">When to Use `ZONE` vs. `REGION` Survival Goals</InternalLink>
* <InternalLink path="table-localities#when-to-use-regional-vs-global-tables">When to Use `REGIONAL` vs. `GLOBAL` Tables</InternalLink>
* <InternalLink path="demo-low-latency-multi-region-deployment">Low Latency Reads and Writes in a Multi-Region Cluster</InternalLink>
* <InternalLink path="migrate-to-multiregion-sql">Migrate to Multi-Region SQL</InternalLink>
* <InternalLink path="multiregion-overview#secondary-regions">Secondary regions</InternalLink>
* <InternalLink path="alter-database#set-secondary-region">`ALTER DATABASE... SET SECONDARY REGION`</InternalLink>
* <InternalLink path="alter-database#drop-secondary-region">`ALTER DATABASE... DROP SECONDARY REGION`</InternalLink>
* <InternalLink path="topology-patterns">Topology Patterns Overview</InternalLink>
  * Single-region patterns
    * <InternalLink path="topology-development">Development</InternalLink>
    * <InternalLink path="topology-basic-production">Basic Production</InternalLink>
  * Multi-region patterns
    * <InternalLink path="regional-tables">`REGIONAL` Tables</InternalLink>
    * <InternalLink path="global-tables">`GLOBAL` Tables</InternalLink>
    * <InternalLink path="topology-follower-reads">Follower Reads</InternalLink>
    * <InternalLink path="topology-follow-the-workload">Follow-the-Workload</InternalLink>
