Guillaume Briday
Paris.rb - January 7, 2025
Rails 8 only requires a database as a dependency.
And it can be SQLite.It replaces the traditional RAM-based solutions like Redis with efficient, cost-effective database-backed tools.
Size | Price | Performance | |
---|---|---|---|
Redis | π€ | π΅π΅π΅ | ποΈποΈποΈ |
Database | π | π΅ | ποΈποΈ |
Size | Price | |
---|---|---|
Heroku | 500MB | $120/m |
Scalingo | 4GB | β¬115/m |
Scaleway | 8c/16t 64GB 2TB NVMe | β¬120/m |
A balance between speed and cache miss rate.
production:
primary:
<<: *default
host: <%= ENV["POSTGRES_HOST"] %>
cache:
<<: *default
host: <%= ENV["CACHE_POSTGRES_HOST"] %>
migrations_paths: db/cache_migrate
queue:
<<: *default
host: <%= ENV["QUEUE_POSTGRES_HOST"] %>
migrations_paths: db/queue_migrate
# Replace the default in-process memory cache store with a durable alternative.
config.cache_store = :solid_cache_store
# Replace the default in-process and non-durable queuing backend for Active Job.
config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :queue } }
---
scaleway_image: "69f43bac-da9b-49e3-b4fd-b826bef91e22"
scaleway_organization: "..."
scaleway_api_token: "..."
scaleway_commercial_type: "DEV1-L"
scaleway_region: "par1"
scaleway_public_ip: "dynamic"
scaleway_state: "running"
scaleway_instances:
- app-1
- worker-1
- primary-db
- queue-db
- cache-db
$ ansible-playbook scaleway.yml
servers:
web:
- 192.168.0.1
job:
hosts:
- 192.168.0.2
cmd: bin/jobs
env:
clear:
POSTGRES_HOST: "192.168.0.3"
QUEUE_POSTGRES_HOST: "192.168.0.4"
CACHE_POSTGRES_HOST: "192.168.0.5"
secret:
- POSTGRES_USER
- POSTGRES_DB
- POSTGRES_PASSWORD
accessories:
db:
image: postgres:16
host: 192.168.0.3
port: 5432
env:
secret:
- POSTGRES_USER
- POSTGRES_DB
- POSTGRES_PASSWORD
queue-db:
image: postgres:16
host: 192.168.0.4
port: 5432
env:
secret:
- POSTGRES_USER
- POSTGRES_DB
- POSTGRES_PASSWORD
cache-db:
image: postgres:16
host: 192.168.0.5
port: 5432
env:
secret:
- POSTGRES_USER
- POSTGRES_DB
- POSTGRES_PASSWORD
$ kamal setup # or kamal deploy