4 ms·
One thing I don't get about the current Rails direction is pushing hard to use SQLite and removing external dependencies but at the same time also advocating to
by nickjj 2y ago
One thing I don't get about the current Rails direction is pushing hard to use SQLite and removing external dependencies but at the same time also advocating to use Docker.
Running Postgres and Redis in Docker is a matter of adding a few lines of YAML to a file once and never thinking about it again. I have done this for 10 years, it is painless.
I'm all for reducing moving parts and would also choose the same strategy if there were no down sides but DHH is running their apps on dedicated hardware with some of the best performing SSDs you can get. Most VPS providers have a lot worse disk performance.
There's also downsides to running your DB (SQLite or Postgres) directly on your single VPS when it comes to uptime. If your server is stateless then you can upgrade it with zero downtime. All you have to do is spin up a new server, provision it, add it to DNS, wait a day or 2 and then decommission the old one. This is nice for resizing instances or big OS updates in a zero risk way. You can just make a new server.
That works because it doesn't matter if the old or new server is writing to your externally hosted DB. If your DB is directly on the host or using block storage that can only be connected to one instance at a time then you can't spin up a new server since one of the DBs will get out of date.
- wiseowise 2y ago> I have done this for 10 years > it is painless Huh, I wonder why.
- nickjj 2y ago> Huh, I wonder why. I didn't start with 10 years of experience if that's what you mean. A basic Redis config inside of Docker Compose could be: services: redis: image: "redis:7.4.1-bookworm" restart: "unless-stopped" volumes: - "redis:/data" volumes: redis: {} Now you have Redis running with your project and you can use "redis" as the hostname to connect from your app. It even persists to disk with a volume if needed. It's similar for Postgres except you'd also want to set the PG username and password with environment variables so your initial user and DB get set up with reasonable defaults. A working version of this is in my Rails starter app at: https://github.com/nickjj/docker-rails-example https://github.com/nickjj/docker-rails-example It sets a few more properties but those aren't essential to get going.
- e12e 2y agoAgreed. Adding SQLite is potentially a quick way to make your stateless rails container/app stateful. While using a proper DBMS as a separate service makes perfect sense.