Databases and storage
We pick PostgreSQL and SQLite for data, Redis or Valkey for caches and jobs, an open ORM, Postgres search, and SeaweedFS for files.
- Recommended 8
- Avoid 2
Recommended
Use PostgreSQL for the main database
Recommended 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
Recommended 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 Redis 8 or Valkey for caches and queues
Recommended Open sourceRun Redis 8 or later, or Valkey, for caches, rate limits and job queues. Never run Redis 7.4 to 7.8, whose licences are not open source.
Use a mature ORM for database code
Recommended 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
Recommended Open sourceChange the schema with the migration tool of the ORM you use, which is Prisma Migrate, Alembic for SQLAlchemy or Django migrations.
Use PostgreSQL search first and OpenSearch when it falls short
Recommended 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
Recommended 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
Recommended Open sourceRun slow or retried work in background jobs with BullMQ in Node.js or RQ in Python, both on Redis or Valkey.
Avoid
Avoid MongoDB as the default database
Avoid Source availableDo not pick MongoDB Community Server as the main database of a new web app.
Avoid the MinIO community edition
Avoid 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. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/databases-and-storage. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.