Skip to content

Latest commit

 

History

History
133 lines (81 loc) · 5.51 KB

deploy-cockroachdb-on-aws.md

File metadata and controls

133 lines (81 loc) · 5.51 KB
title summary toc toc_not_nested ssh-link
Deploy CockroachDB on AWS EC2
Learn how to deploy CockroachDB on Amazon's AWS EC2 platform.
false
true
Secure Insecure

This page shows you how to manually deploy a secure multi-node CockroachDB cluster on Amazon's AWS EC2 platform, using AWS's managed load balancing service to distribute client traffic.

If you are only testing CockroachDB, or you are not concerned with protecting network communication with TLS encryption, you can use an insecure cluster instead. Select Insecure above for instructions.

Requirements

{% include prod_deployment/secure-requirements.md %}

Recommendations

{% include prod_deployment/secure-recommendations.md %}

  • All instances running CockroachDB should be members of the same Security Group.

Step 1. Configure your network

CockroachDB requires TCP communication on two ports:

  • 26257 for inter-node communication (i.e., working as a cluster), for applications to connect to the load balancer, and for routing from the load balancer to nodes
  • 8080 for exposing your Admin UI

You can create these rules using Security Groups' Inbound Rules.

Inter-node and load balancer-node communication

Field Recommended Value
Type Custom TCP Rule
Protocol TCP
Port Range 26257
Source The name of your security group (e.g., sg-07ab277a)

Admin UI

Field Recommended Value
Type Custom TCP Rule
Protocol TCP
Port Range 8080
Source Your network's IP ranges

Application data

Field Recommended Value
Type Custom TCP Rules
Protocol TCP
Port Range 26257
Source Your application's IP ranges

Step 2. Create instances

Create an instance for each node you plan to have in your cluster.

  • Run at least 3 nodes to ensure survivability.

  • Use m (general purpose), c (compute-optimized), or i (storage-optimized) instances, with SSD-backed EBS volumes or Instance Store volumes. For example, Cockroach Labs has used m3.large instances (2 vCPUs and 7.5 GiB of RAM per instance) for internal testing.

  • Do not use "burstable" t2 instances, which limit the load on a single core.

For more details, see Hardware Recommendations and Cluster Topology.

Step 3. Synchronize clocks

{% include prod_deployment/synchronize-clocks.md %}

Step 4. Set up load balancing

Each CockroachDB node is an equally suitable SQL gateway to your cluster, but to ensure client performance and reliability, it's important to use load balancing:

  • Performance: Load balancers spread client traffic across nodes. This prevents any one node from being overwhelmed by requests and improves overall cluster performance (queries per second).

  • Reliability: Load balancers decouple client health from the health of a single CockroachDB node. In cases where a node fails, the load balancer redirects client traffic to available nodes.

AWS offers fully-managed load balancing to distribute traffic between instances.

  1. Add AWS load balancing. Be sure to:
    • Set forwarding rules to route TCP traffic from the load balancer's port 26257 to port 26257 on the nodes.
    • Configure health checks to use HTTP port 8080 and path /health?ready=1. This health endpoint ensures that load balancers don't direct traffic to nodes that are live but not ready to receive requests.
  2. Note the provisioned IP Address for the load balancer. You'll use this later to test load balancing and to connect your application to the cluster.

{{site.data.alerts.callout_info}}If you would prefer to use HAProxy instead of AWS's managed load balancing, see the On-Premises tutorial for guidance.{{site.data.alerts.end}}

Step 5. Generate certificates

{% include prod_deployment/secure-generate-certificates.md %}

Step 6. Start nodes

{% include prod_deployment/secure-start-nodes.md %}

Step 7. Initialize the cluster

{% include prod_deployment/secure-initialize-cluster.md %}

Step 8. Test your cluster

{% include prod_deployment/secure-test-cluster.md %}

Step 9. Test load balancing

{% include prod_deployment/secure-test-load-balancing.md %}

Step 10. Use the database

{% include prod_deployment/use-cluster.md %}

Step 11. Set up monitoring and alerting

{% include prod_deployment/monitor-cluster.md %}

Step 12. Scale the cluster

{% include prod_deployment/secure-scale-cluster.md %}

See Also

{% include prod_deployment/prod-see-also.md %}