Skip to content

Commit 432607c

Browse files
committed
Draft cloud database doc
1 parent 3659ffd commit 432607c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

practices/cloud-databases.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Cloud databases
2+
3+
- [Cloud databases](#cloud-databases)
4+
- [Context](#context)
5+
- [Details](#details)
6+
- [Choosing the type of database you need](#choosing-the-type-of-database-you-need)
7+
- [Infrastructure](#infrastructure)
8+
9+
## Context
10+
11+
- These notes are part of a broader set of [principles](../principles.md)
12+
- Practices in this section contribute to [service reliability](service-reliability.md)
13+
- See also [observability](observability.md)
14+
15+
## Details
16+
17+
### Choosing the type of database you need
18+
19+
Do not reflexively reach for a specific database product without considering whether it matches your use case. In general you should prefer relational stores because of their feature set and design choices which make them broadly applicable. Choose a non-relational store only if the trade-off makes sense for your application. An example would be needing extremely high write rates (in the range of millions of operations per minute) where eventual consistency is tolerable: in that case DynamoDB or equivalent may be appropriate.
20+
21+
Prefer to learn how to use the right tool for the job over picking the tool a team happens to be familiar with.
22+
23+
### Infrastructure
24+
25+
Successfully operating relational databases in a cloud environment, especially a serverless one, requires attention to the specific qualities of the database products as implemented by the cloud platforms.
26+
27+
- Do use a small number of long-lived server instances. Do not create new servers per application environment. Database servers can be very slow to instantiate, which means that tools like `terraform` can time out waiting for them to start. Instead separate your infrastructure code so that your servers are configured once per AWS account. The `terraform` code that configures an application instance should provision its resources by calling into the already-provisioned server in the account to create environment-specific databases.
28+
- Do manage your database migrations. Use a tool like `alembic`, or an alternative. If building a serverless application, deploy your migrations into a cloud function that will be called by your `terraform` deployment.
29+
- Learn how to refactor database schemas safely. Several coupled migrations and code changes may be needed to successfully change the schema with no downtime.

0 commit comments

Comments
 (0)