News for hackers. Stuff that matters.
Re:Rails on Docker · Fly by agtorre on Thursday January 26, 2023 @11:56AM (#34534411)
This is really cool. Is the Rails server production ready? I was always under the impression you had to run it with Uvicorn or similar, although I haven't been following Rails development recently.
Re:Rails on Docker · Fly by grk on Thursday January 26, 2023 @12:01PM (#34534512)
The default Gemfile now bundles Puma in, so yeah it's production ready
Re:Rails on Docker · Fly by e12e on Friday January 27, 2023 @08:59AM (#34546071)
Puma is certainly fine as the app server - but normally you'd still have a proxy/load balancer/tls terminator/"ingress server" in front. Something like traefik, nginx, haproxy or caddy.

If (one of the) front-facing servers do regular http caching (a good idea anyway to play nice with rails caching[1])", you can probably "serve" the static assets straight from rails and let your proxy serve them from cache (if you don't have/need a full cdn).

[1] https://guides.rubyonrails.org/caching_with_rails.html#condi...

Re:Rails on Docker · Fly by dewey on Thursday January 26, 2023 @12:51PM (#34535523)
Yes, usually you still serve your asset (images,...) directory through nginx or something similar, though.
Re:Rails on Docker · Fly by ye-olde-sysrq on Thursday January 26, 2023 @04:31PM (#34539123)
This has been my experience too, and I've never even used Rails at scale. Puma will struggle to serve "lots" (tens on a single page) of (for example) static images (though the actual user experience varies across browsers - safari does okay but firefox chokes and chromium is in the middle). This is with puma on a decent intel prosumer CPU (an i7 iirc) using x-sendfiles through nginx. So puma isn't even actually pushing the image bytes here.

I replaced it with nginx intercepting the image URLs to serve them without even letting puma know and it was instantly zippy. I still use sendfile to support when I'm doing dev and not running nginx in front of it, and I'm not happy with the kind of leaky abstraction there, but damn are the benefits in prod too difficult to ignore.

Re:Rails on Docker · Fly by jrochkind1 on Thursday January 26, 2023 @06:31PM (#34540363)
Serving the assets directly with the Rails app, but with a CDN caching layer in front, is also common, and is what heroku for instance recommends.