💎 Ruby on Rails
Advanced
What is the role of Puma in Rails deployment?
Answer
Puma is Rails' default web server (since Rails 5). It is a concurrent, multi-threaded Rack server designed for production. Key features: multi-threaded (handles multiple requests per process simultaneously using threads — allows connection pool sharing), cluster mode (multiple worker processes, each multi-threaded — called "workers" + "threads"), and socket binding (can listen on TCP or Unix sockets). Configure via config/puma.rb: workers ENV.fetch("WEB_CONCURRENCY") { 2 }; threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }. In production, Puma sits behind Nginx (reverse proxy + static file serving). Puma handles graceful restarts (phased-restart) for zero-downtime deploys.
More Ruby on Rails Questions
View all →- Advanced What is metaprogramming in Ruby/Rails and give examples?
- Advanced What is the difference between include, extend, and prepend in Ruby?
- Advanced How does Rails handle database connection pooling?
- Advanced What is Rack and how does Rails relate to it?
- Advanced What is query optimization with explain in Rails?