CHAPTER 16 · Scaling and Infrastructure · 6 / 10
Data tier scaling
The database and storage have their own scaling story:
- Connection pooling. Many app instances × many connections can overwhelm a database; use a pooler. (Note that schema-migration/DDL connections sometimes need a separate, unpooled path.)
- Indexing for access paths. Index the columns your hot queries filter and sort on (per-user, per-project, per-document-by-time). Avoid N+1 queries by batching lookups (e.g. resolve many artifacts' current versions in one query).
- Object storage for blobs. Keep large content in object storage, the database for metadata and pointers (Chapter 9). Object storage scales effectively infinitely; your database stays lean.
- Read/write patterns. As you grow, consider read replicas for heavy read paths, and keep write paths (the turn-persistence) lean.