Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 83 lines (42 sloc) 3.691 kb
43cb200 @evanphx Switch README to format hoe understands
evanphx authored
1 # Puma: A Ruby Web Server Built For Concurrency
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
2
43cb200 @evanphx Switch README to format hoe understands
evanphx authored
3 ## Description
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
4
225b556 @kyledrake Update README file to provide more details
kyledrake authored
5 Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby web applications. It can be used with any application that supports Rack, and is considered the replacement for Webrick and Mongrel. It was designed to be the go-to server for [Rubinius](http://rubini.us), but also works well with JRuby and MRI. Puma is intended for use in both development and production environments.
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
6
cc2ca8a @kyledrake Fix extension typo
kyledrake authored
7 Under the hood, 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 in a thread from an internal thread pool (which you can control). This allows Puma to provide real concurrency for your web application!
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
8
225b556 @kyledrake Update README file to provide more details
kyledrake authored
9 With Rubinius 2.0, Puma will utilize all cores on your CPU with real threads, meaning you won't have to spawn multiple processes to increase throughput. You can expect to see a similar benefit from JRuby.
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
10
50eae0d @kyledrake Link to JRuby
kyledrake authored
11 On MRI, there is a Global Interpreter Lock (GIL) that ensures only one thread can be run 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 blocking IO to be run concurrently (EventMachine-based servers such as Thin turn off this ability, requiring you to use special libraries). Your mileage may vary.. in order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like [Rubinius](http://rubini.us) or [JRuby](http://jruby.org).
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
12
43cb200 @evanphx Switch README to format hoe understands
evanphx authored
13 ## Quick Start
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
14
225b556 @kyledrake Update README file to provide more details
kyledrake authored
15 The easiest way to get started with Puma is to install it via RubyGems. You can do this easily:
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
16
06072d0 @tarcieri Indent examples at the level Markdown expects
tarcieri authored
17 $ gem install puma
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
18
225b556 @kyledrake Update README file to provide more details
kyledrake authored
19 Now you should have the puma command available in your PATH, so just do the following in the root folder of your Rack application:
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
20
4f69300 @evanphx Prune the README.md
evanphx authored
21 $ puma app.ru
1888887 @tarcieri Redo README in Markdown and replace Mongrel with Puma
tarcieri authored
22
7a9a8e2 @rkh Add documentation for Rails/Sinatra/Rack usage
rkh authored
23 ## Advanced Setup
24
25 ### Sinatra
26
27 You can run your Sinatra application with Puma from the command line like this:
28
29 $ ruby app.rb -s Puma
30
31 Or you can configure your application to always use Puma:
32
33 require 'sinatra'
34 configure { set :server, :puma }
35
36 If you use Bundler, make sure you add Puma to your Gemfile (see below).
37
38 ### Rails
39
40 First, make sure Puma is in your Gemfile:
41
42 gem 'puma'
43
44 Then start your server with the `rails` command:
45
46 $ rails s puma
47
48 ### Rackup
49
50 You can pass it as an option to `rackup`:
51
52 $ rackup -s puma
53
54 Alternatively, you can modify your `config.ru` to choose Puma by default, by adding the following as the first line:
55
56 #\ -s puma
225b556 @kyledrake Update README file to provide more details
kyledrake authored
57
58 ## Configuration
59
60 Puma provides numerous options for controlling the operation of the server. Consult `puma -h` (or `puma --help`) for a full list.
61
62 ### Thread Pool
63
64 Puma utilizes a dynamic thread pool which you can modify. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
65
66 $ puma -t 8:32
67
68 Puma will automatically scale the number of threads 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 very large number, as you may exhaust resources on the system (or hit resource limits).
69
70 ### Binding TCP / Sockets
71
72 In contrast to many server configs, Puma simply uses takes one URI parameter with the `-b` (or `--bind`) flag:
73
74 $ puma -b tcp://127.0.0.1:9292
75
76 Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)? No problem!
77
78 $ puma -b unix:///var/run/puma.sock
79
80 ## License
81
82 Puma is copyright 2011 Evan Phoenix and contributors. It is licensed under the BSD license. See the include LICENSE file for details.
Something went wrong with that request. Please try again.