Skip to content
A Ruby/Rack web server built for concurrency
Ruby C Java Shell Ragel PowerShell Other
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Allow reversed words to skip changelog [skip ci] (#2021) Oct 10, 2019
benchmarks/wrk Add benchmarks for large request bodies and responses Oct 13, 2019
bin Fix puma-wild handling a restart properly. Fixes #550 Oct 30, 2014
docs Apply @Jesus' plugin docs reformatting from #1849 Oct 2, 2019
examples Merge files documenting configuration options (#1883) Aug 6, 2019
ext/puma_http11 Merge branch 'jruby_optz' of into hea… Oct 7, 2019
lib Don't allow EINVAL to raise during SSL addr check Oct 7, 2019
test Add benchmarks for large request bodies and responses Oct 13, 2019
tools Example Dockerfile for issue reproduction Sep 19, 2019
win_gem_test update puma.ps1 for nio4r & Ruby 2.2 [skip travis] (#1872) Jul 30, 2019
.codeclimate.yml Codeclimate: exclude extensions Sep 20, 2019
.gitattributes Stop the CRLF warnings Jan 25, 2019
.gitignore Appveyor - Create pre-compiled Windows gems and test Sep 11, 2018
.rubocop.yml Revert "[close #1811] Minimum Ruby version >= 2.5" Jun 14, 2019
.rubocop_todo.yml Use Rubocop 0.50; fix SpaceBeforeBlockBraces layout (#1472) Nov 30, 2017
.travis.yml travis.yml - allow JRuby jobs to start first (#2028) Oct 11, 2019 Create Aug 5, 2019 Add a few things to CONTRIBUTING Oct 16, 2019
Gemfile Revert "Require nio4r >= 2.5 for dev/CI" Oct 11, 2019 Fix-up Markdown in [ci skip] Oct 10, 2019
LICENSE Update license Sep 24, 2011 Add contribution guide [ci skip] (#2034) Oct 16, 2019
Rakefile Cleanup Rakefile (#1847) Jul 16, 2019 v 3.11.4 Apr 12, 2018
puma.gemspec Add changelog uri to spec metadata (#1911) Aug 15, 2019

Puma: A Ruby Web Server Built For Concurrency

Gitter Actions Build Status Travis Build Status

Code Climate SemVer

Puma is a simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications.

Built For Speed & Concurrency

Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.

Puma was designed to be the go-to server for Rubinius, but also works well with JRuby and MRI.

On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel.

Quick Start

$ gem install puma
$ puma

Without arguments, puma will look for a rackup (.ru) file in the current working directory called



Puma is the default server for Rails, included in the generated Gemfile.

Start your server with the rails command:

$ rails server

Many configuration options and Puma features are not available when using rails server. It is recommended that you use Puma's executable instead:

$ bundle exec puma


You can run your Sinatra application with Puma from the command line like this:

$ ruby app.rb -s Puma

Or you can configure your Sinatra application to always use Puma:

require 'sinatra'
configure { set :server, :puma }


Puma provides numerous options. Consult puma -h (or puma --help) for a full list of CLI options, or see dsl.rb.

You can also find several configuration examples as part of the test suite.

Thread Pool

Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the -t (or --threads) flag:

$ puma -t 8:32

Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is 0:16. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or cause contention for the Global VM Lock, when using MRI).

Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.

Clustered mode

Puma also offers "clustered mode". Clustered mode forks workers from a master process. Each child process still has its own thread pool. You can tune the number of workers with the -w (or --workers) flag:

$ puma -t 8:32 -w 3

Note that threads are still used in clustered mode, and the -t thread flag setting is per worker, so -w 2 -t 16:16 will spawn 32 threads in total, with 16 in each worker process.

In clustered mode, Puma can "preload" your application. This loads all the application code prior to forking. Preloading reduces total memory usage of your application via an operating system feature called copy-on-write (Ruby 2.0+ only). Use the --preload flag from the command line:

$ puma -w 3 --preload

If you're using a configuration file, use the preload_app! method:

# config/puma.rb
workers 3

Additionally, you can specify a block in your configuration file that will be run on boot of each worker:

# config/puma.rb
on_worker_boot do
  # configuration here

This code can be used to setup the process before booting the application, allowing you to do some Puma-specific things that you don't want to embed in your application. For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.

before_fork specifies a block to be run before workers are forked:

# config/puma.rb
before_fork do
  # configuration here

Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app copies the code of master into the workers.

Error handling

If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple textual error message (see lowlevel_error in this file). You can specify custom behavior for this scenario. For example, you can report the error to your third-party error-tracking service (in this example, rollbar):

lowlevel_error_handler do |e|
  [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact\n"]]

Binding TCP / Sockets

Bind Puma to a socket with the -b (or --bind) flag:

$ puma -b tcp://

To use a UNIX Socket instead of TCP:

$ puma -b unix:///var/run/puma.sock

If you need to change the permissions of the UNIX socket, just add a umask parameter:

$ puma -b 'unix:///var/run/puma.sock?umask=0111'

Need a bit of security? Use SSL sockets:

$ puma -b 'ssl://'

Controlling SSL Cipher Suites

To use or avoid specific SSL cipher suites, use ssl_cipher_filter or ssl_cipher_list options.

$ puma -b 'ssl://!aNULL:AES+SHA'
$ puma -b 'ssl://,TLS_RSA_WITH_AES_256_CBC_SHA'

See for cipher filter format and full list of cipher suites.

Disable TLS v1 with the no_tlsv1 option:

$ puma -b 'ssl://'

Control/Status Server

Puma has a built-in status and control app that can be used to query and control Puma.

$ puma --control-url tcp:// --control-token foo

Puma will start the control server on localhost port 9293. All requests to the control server will need to include control token (in this case, token=foo) as a query parameter. This allows for simple authentication. Check out status.rb to see what the status app has available.

You can also interact with the control server via pumactl. This command will restart Puma:

$ pumactl --control-url 'tcp://' --control-token foo restart

To see a list of pumactl options, use pumactl --help.

Configuration File

You can also provide a configuration file with the -C (or --config) flag:

$ puma -C /path/to/config

If no configuration file is specified, Puma will look for a configuration file at config/puma.rb. If an environment is specified, either via the -e and --environment flags, or through the RACK_ENV environment variable, Puma looks for configuration at config/puma/<environment_name>.rb.

If you want to prevent Puma from looking for a configuration file in those locations, provide a dash as the argument to the -C (or --config) flag:

$ puma -C "-"

Check out dsl.rb to see all available options.


Puma includes the ability to restart itself. When available (MRI, Rubinius, JRuby), Puma performs a "hot restart". This is the same functionality available in Unicorn and NGINX which keep the server sockets open between restarts. This makes sure that no pending requests are dropped while the restart is taking place.

For more, see the restart documentation.


Puma responds to several signals. A detailed guide to using UNIX signals with Puma can be found in the signals documentation.

Platform Constraints

Some platforms do not support all Puma features.

  • JRuby, Windows: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to Ruby. Also, cluster mode is not supported due to a lack of fork(2).
  • Windows: Cluster mode is not supported due to a lack of fork(2).

Known Bugs

For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.2.10 2.3.4 and 2.4.1, you may see stream closed in another thread (IOError). It may be caused by a Ruby bug. It can be fixed with the gem

if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
    require 'stopgap_13632'
  rescue LoadError


Puma has support for Capistrano with an external gem.

It is common to use process monitors with Puma. Modern process monitors like systemd or upstart provide continuous monitoring and restarts for increased reliability in production environments:

Community Plugins


Find details for contributing in the contribution guide.


Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.

You can’t perform that action at this time.