Databases and storage
We pick PostgreSQL and SQLite for data, Redis or Valkey for caches and jobs, and an open ORM. Postgres search, SeaweedFS and ClamAV do the rest.
- Default 11
- Recommended 2
- Avoid 2
Default
Use PostgreSQL for the main database
STK-28 Open sourceKeep the main business data of a web app in PostgreSQL, on a major version with more than 12 months of support left.
Use SQLite for a small or embedded database
STK-29 Open sourceUse SQLite when one server process owns the data. Examples are a small site, a phone app, a test suite or a local tool.
Use PgBouncer when many app servers share PostgreSQL
STK-93 Open sourcePut PgBouncer in transaction mode between your app servers and PostgreSQL when their pools together could pass the database's connection limit.
Use Redis 8 or Valkey for caches and queues
STK-30 Open sourceRun Redis 8 or later, or Valkey, for caches, rate limits and job queues. Never run Redis 7.4, the one community line whose licences are not open source.
Use PostgreSQL search first and OpenSearch when it falls short
STK-33 Open sourceBuild search on PostgreSQL full-text search first. Add OpenSearch only when a measured need fails in PostgreSQL.
Use the S3 API for files and SeaweedFS to host them
STK-34 Open sourceKeep uploads and other files in object storage reached through the S3 API, with the endpoint and bucket in settings. Host it yourself on SeaweedFS.
Use BullMQ or RQ for background jobs
STK-35 Open sourceRun slow or retried work in background jobs with BullMQ in Node.js or RQ in Python, both on Redis or Valkey.
Use RabbitMQ for messages between services and Kafka for event streams
STK-104 Open sourceWhen two or more services pass messages, send them through RabbitMQ. Use Kafka instead when consumers must read the same events again from a stored log.
Use Temporal for long workflows that must survive restarts
STK-105 Open sourceRun a business process that spans several steps, services or days as a Temporal workflow, not as a hand-made chain of queues and status columns. An order from payment to delivery is one example.
Use ClickHouse when analytics outgrow PostgreSQL
STK-106 Open sourceKeep reports on PostgreSQL until a report query takes longer than its budget on a read replica. Then copy the event data into ClickHouse and run the reports there.
Use ClamAV to scan uploaded files
STK-94 Open sourceScan every uploaded file with ClamAV on its long-term support line, and fetch new signatures at least once a day.
Recommended
Use a mature ORM for database code
STK-31 Open sourceWrite database code with Prisma in TypeScript and SQLAlchemy in Python, or with the Django ORM inside a Django project. Keep one ORM per codebase.
Use the migration tool that comes with your ORM
STK-32 Open sourceChange the schema with the migration tool of the ORM you use, which is Prisma Migrate, Alembic for SQLAlchemy or Django migrations.
Avoid
Avoid MongoDB as the default database
STK-36 Source availableDo not pick MongoDB Community Server as the main database of a new web app.
Avoid the MinIO community edition
STK-37 Open sourceDo not start new self-hosted object storage on the MinIO community edition, and plan a move off it.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/databases-and-storage">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.