puma 3.12.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d0e3b5d74ced5d332fa04832c60b4b8b9c16514f3441cefea046d6ca4948025
4
- data.tar.gz: 9462d0f9e3357c2b245f194b43281e5f8e5ebf0ee981e7658a938d880e3e4404
3
+ metadata.gz: 4564625669c77dfcd7e4096c40f8b24cb3b7b5a938b97309bbb193566ae0869e
4
+ data.tar.gz: 88ae06dc5193587a114ef4f6cec79ad8001333ef9b3fff5c839fd3eea75cf746
5
5
  SHA512:
6
- metadata.gz: 19ffe686429f3271d947e8fbc73c1e55113a0ad22eea2a194c80abac60cf675ea4162675f99d641e18e91d1d4270eae80644ccab5667ad263dfb32eb0b3075f2
7
- data.tar.gz: 40876e43164a6103bcfc560a6034f4fb2215d0da39d84cb5d53f961da64a8d8e41e3f239f1a7886a0f13c6e6a1357608a54efc009517e1b3b2afc72c4a570b8d
6
+ metadata.gz: ec7c5afdb5cb46e8827ad83c189240e426efab3aaf7b4ac9ef5b2d7977203a30495dd082c08b96299b6c050022da57af28065dfe37f5271e50138ab34e81512f
7
+ data.tar.gz: 81728699a0f8c0c135f72bd03b6fbb76c405f7bcc138a2f918a4abb6978334528e0e004851fa58da254e6c6abb074cc35401835d61d2a3b2e5d9f2134fd10dff
data/History.md CHANGED
@@ -1,10 +1,71 @@
1
1
  ## Master
2
2
 
3
- * x features
4
-
5
- * x bugfixes
6
-
7
- ## 3.12.1 / 2019-01-08
3
+ * Features
4
+ * Your feature goes here (#Github Number)
5
+
6
+ * Bugfixes
7
+ * Your bugfix goes here (#Github Number)
8
+
9
+ ## 4.1.0 / 2019-08-08
10
+
11
+ * 4 features
12
+ * Add REQUEST_PATH on parse error message (#1831)
13
+ * You can now easily add custom log formatters with the `log_formatter` config option (#1816)
14
+ * Puma.stats now provides process start times (#1844)
15
+ * Add support for disabling TLSv1.1 (#1836)
16
+
17
+ * 7 bugfixes
18
+ * Fix issue where Puma was creating zombie process entries (#1887)
19
+ * Fix bugs with line-endings and chunked encoding (#1812)
20
+ * RACK_URL_SCHEME is now set correctly in all conditions (#1491)
21
+ * We no longer mutate global STDOUT/STDERR, particularly the sync setting (#1837)
22
+ * SSL read_nonblock no longer blocks (#1857)
23
+ * Swallow connection errors when sending early hints (#1822)
24
+ * Backtrace no longer dumped when invalid pumactl commands are run (#1863)
25
+
26
+ * 5 other
27
+ * Avoid casting worker_timeout twice (#1838)
28
+ * Removed a call to private that wasn't doing anything (#1882)
29
+ * README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
30
+ * Puma.io has proper documentation now (https://puma.io/puma/)
31
+ * Added the Contributor Covenant CoC
32
+
33
+ * 1 known issue
34
+ * Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
35
+
36
+ ## 4.0.1 / 2019-07-11
37
+
38
+ * 2 bugfixes
39
+ * Fix socket removed after reload - should fix problems with systemd socket activation. (#1829)
40
+ * Add extconf tests for DTLS_method & TLS_server_method, use in minissl.rb. Should fix "undefined symbol: DTLS_method" when compiling against old OpenSSL versions. (#1832)
41
+ * 1 other
42
+ * Removed unnecessary RUBY_VERSION checks. (#1827)
43
+
44
+ ## 4.0.0 / 2019-06-25
45
+
46
+ * 9 features
47
+ * Add support for disabling TLSv1.0 (#1562)
48
+ * Request body read time metric (#1569)
49
+ * Add out_of_band hook (#1648)
50
+ * Re-implement (native) IOBuffer for JRuby (#1691)
51
+ * Min worker timeout (#1716)
52
+ * Add option to suppress SignalException on SIGTERM (#1690)
53
+ * Allow mutual TLS CA to be set using `ssl_bind` DSL (#1689)
54
+ * Reactor now uses nio4r instead of `select` (#1728)
55
+ * Add status to pumactl with pidfile (#1824)
56
+
57
+ * 9 bugfixes
58
+ * Do not accept new requests on shutdown (#1685, #1808)
59
+ * Fix 3 corner cases when request body is chunked (#1508)
60
+ * Change pid existence check's condition branches (#1650)
61
+ * Don't call .stop on a server that doesn't exist (#1655)
62
+ * Implemented NID_X9_62_prime256v1 (P-256) curve over P-521 (#1671)
63
+ * Fix @notify.close can't modify frozen IOError (RuntimeError) (#1583)
64
+ * Fix Java 8 support (#1773)
65
+ * Fix error `uninitialized constant Puma::Cluster` (#1731)
66
+ * Fix `not_token` being able to be set to true (#1803)
67
+
68
+ ## 3.12.1 / 2019-03-19
8
69
 
9
70
  * 1 features
10
71
  * Internal strings are frozen (#1649)
@@ -1410,3 +1471,12 @@ be added back in a future date when a java Puma::MiniSSL is added.
1410
1471
  ## 1.0.0 / 2012-03-29
1411
1472
 
1412
1473
  * Released!
1474
+
1475
+ ## Ignore - this is for maintainers to copy-paste during release
1476
+ ## Master
1477
+
1478
+ * Features
1479
+ * Your feature goes here (#Github Number)
1480
+
1481
+ * Bugfixes
1482
+ * Your bugfix goes here (#Github Number)
data/README.md CHANGED
@@ -1,45 +1,47 @@
1
1
  <p align="center">
2
- <img src="http://puma.io/images/logos/puma-logo-large.png">
2
+ <img src="https://puma.io/images/logos/puma-logo-large.png">
3
3
  </p>
4
4
 
5
5
  # Puma: A Ruby Web Server Built For Concurrency
6
6
 
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
8
- [![Build Status](https://secure.travis-ci.org/puma/puma.svg)](http://travis-ci.org/puma/puma)
9
- [![AppVeyor](https://img.shields.io/appveyor/ci/nateberkopec/puma.svg)](https://ci.appveyor.com/project/nateberkopec/puma)
10
- [![Dependency Status](https://gemnasium.com/puma/puma.svg)](https://gemnasium.com/puma/puma)
8
+ [![Travis Build Status](https://secure.travis-ci.org/puma/puma.svg)](https://travis-ci.org/puma/puma)
9
+ [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/0xnxc7a26u9b2bub/branch/master?svg=true)](https://ci.appveyor.com/project/puma/puma/branch/master)
11
10
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
11
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
12
12
 
13
- Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications** in development and production.
13
+ Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications**.
14
14
 
15
15
  ## Built For Speed &amp; Concurrency
16
16
 
17
- 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. Since each request is served in a separate thread, truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
17
+ 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.
18
18
 
19
- Puma was designed to be the go-to server for [Rubinius](http://rubini.us), but also works well with JRuby and MRI.
19
+ Puma was designed to be the go-to server for [Rubinius](https://rubini.us), but also works well with JRuby and MRI.
20
20
 
21
- 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 blocking IO to be run concurrently.
21
+ 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.
22
22
 
23
23
  ## Quick Start
24
24
 
25
25
  ```
26
26
  $ gem install puma
27
- $ puma <any rackup (*.ru) file>
28
- ```
27
+ $ puma
28
+ ```
29
+
30
+ Without arguments, puma will look for a rackup (.ru) file in the current working directory called `config.ru`.
29
31
 
30
32
  ## Frameworks
31
33
 
32
34
  ### Rails
33
35
 
34
- Puma is the default server for Rails, and should already be included in your Gemfile.
36
+ Puma is the default server for Rails, included in the generated Gemfile.
35
37
 
36
- Then start your server with the `rails` command:
38
+ Start your server with the `rails` command:
37
39
 
38
40
  ```
39
- $ rails s
41
+ $ rails server
40
42
  ```
41
43
 
42
- Many configuration options are not available when using `rails s`. It is recommended that you use Puma's executable instead:
44
+ Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
43
45
 
44
46
  ```
45
47
  $ bundle exec puma
@@ -53,7 +55,7 @@ You can run your Sinatra application with Puma from the command line like this:
53
55
  $ ruby app.rb -s Puma
54
56
  ```
55
57
 
56
- Or you can configure your application to always use Puma:
58
+ Or you can configure your Sinatra application to always use Puma:
57
59
 
58
60
  ```ruby
59
61
  require 'sinatra'
@@ -64,6 +66,9 @@ configure { set :server, :puma }
64
66
 
65
67
  Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb).
66
68
 
69
+ You can also find several configuration examples as part of the
70
+ [test](test/config) suite.
71
+
67
72
  ### Thread Pool
68
73
 
69
74
  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:
@@ -72,9 +77,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
72
77
  $ puma -t 8:32
73
78
  ```
74
79
 
75
- 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 hit resource limits).
80
+ 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).
76
81
 
77
- 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.
82
+ 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.
78
83
 
79
84
  ### Clustered mode
80
85
 
@@ -84,9 +89,9 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
84
89
  $ puma -t 8:32 -w 3
85
90
  ```
86
91
 
87
- 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.
92
+ 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.
88
93
 
89
- In clustered mode, Puma may "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](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
94
+ 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](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
90
95
 
91
96
  ```
92
97
  $ puma -w 3 --preload
@@ -111,8 +116,7 @@ end
111
116
 
112
117
  This code can be used to setup the process before booting the application, allowing
113
118
  you to do some Puma-specific things that you don't want to embed in your application.
114
- For instance, you could fire a log notification that a worker booted or send something to statsd.
115
- This can be called multiple times.
119
+ For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
116
120
 
117
121
  If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
118
122
 
@@ -125,7 +129,7 @@ on_worker_boot do
125
129
  end
126
130
  ```
127
131
 
128
- On top of that, you can specify a block in your configuration file that will be run before workers are forked:
132
+ `before_fork` specifies a block to be run before workers are forked:
129
133
 
130
134
  ```ruby
131
135
  # config/puma.rb
@@ -136,15 +140,29 @@ end
136
140
 
137
141
  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.
138
142
 
143
+ ### Error handling
144
+
145
+ If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
146
+ textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
147
+ You can specify custom behavior for this scenario. For example, you can report the error to your third-party
148
+ error-tracking service (in this example, [rollbar](http://rollbar.com)):
149
+
150
+ ```ruby
151
+ lowlevel_error_handler do |e|
152
+ Rollbar.critical(e)
153
+ [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
154
+ end
155
+ ```
156
+
139
157
  ### Binding TCP / Sockets
140
158
 
141
- In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
159
+ Bind Puma to a socket with the `-b` (or `--bind`) flag:
142
160
 
143
161
  ```
144
162
  $ puma -b tcp://127.0.0.1:9292
145
163
  ```
146
164
 
147
- Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
165
+ To use a UNIX Socket instead of TCP:
148
166
 
149
167
  ```
150
168
  $ puma -b unix:///var/run/puma.sock
@@ -157,30 +175,44 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
157
175
  ```
158
176
 
159
177
  Need a bit of security? Use SSL sockets:
178
+
160
179
  ```
161
180
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
162
181
  ```
182
+
163
183
  #### Controlling SSL Cipher Suites
164
- Need to use or avoid specific SSL cipher suites? Use ssl_cipher_filter or ssl_cipher_list options.
165
- #####Ruby:
184
+
185
+ To use or avoid specific SSL cipher suites, use `ssl_cipher_filter` or `ssl_cipher_list` options.
186
+
187
+ ##### Ruby:
188
+
166
189
  ```
167
190
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&ssl_cipher_filter=!aNULL:AES+SHA'
168
191
  ```
169
- #####JRuby:
192
+
193
+ ##### JRuby:
194
+
170
195
  ```
171
196
  $ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore_password&ssl_cipher_list=TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA'
172
197
  ```
198
+
173
199
  See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
174
200
 
201
+ Disable TLS v1 with the `no_tlsv1` option:
202
+
203
+ ```
204
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
205
+ ```
206
+
175
207
  ### Control/Status Server
176
208
 
177
- Puma has a built-in status/control app that can be used to query and control Puma itself.
209
+ Puma has a built-in status and control app that can be used to query and control Puma.
178
210
 
179
211
  ```
180
212
  $ puma --control-url tcp://127.0.0.1:9293 --control-token foo
181
213
  ```
182
214
 
183
- Puma will start the control server on localhost port 9293. All requests to the control server will need to include `token=foo` as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the app has available.
215
+ 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](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the status app has available.
184
216
 
185
217
  You can also interact with the control server via `pumactl`. This command will restart Puma:
186
218
 
@@ -192,13 +224,13 @@ To see a list of `pumactl` options, use `pumactl --help`.
192
224
 
193
225
  ### Configuration File
194
226
 
195
- You can also provide a configuration file which Puma will use with the `-C` (or `--config`) flag:
227
+ You can also provide a configuration file with the `-C` (or `--config`) flag:
196
228
 
197
229
  ```
198
230
  $ puma -C /path/to/config
199
231
  ```
200
232
 
201
- 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, the default file location will be `config/puma/environment_name.rb`.
233
+ 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`.
202
234
 
203
235
  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:
204
236
 
@@ -206,7 +238,7 @@ If you want to prevent Puma from looking for a configuration file in those locat
206
238
  $ puma -C "-"
207
239
  ```
208
240
 
209
- Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
241
+ Check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
210
242
 
211
243
  ## Restart
212
244
 
@@ -223,7 +255,7 @@ Puma responds to several signals. A detailed guide to using UNIX signals with Pu
223
255
  Some platforms do not support all Puma features.
224
256
 
225
257
  * **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).
226
- * **Windows**: daemon mode is not supported due to a lack of fork(2).
258
+ * **Windows**: Cluster mode is not supported due to a lack of fork(2).
227
259
 
228
260
  ## Known Bugs
229
261
 
@@ -249,6 +281,13 @@ reliability in production environments:
249
281
  * [tools/jungle](https://github.com/puma/puma/tree/master/tools/jungle) for sysvinit (init.d) and upstart
250
282
  * [docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md)
251
283
 
284
+ ## Community Plugins
285
+
286
+ * [puma-heroku](https://github.com/evanphx/puma-heroku) — default Puma configuration for running on Heroku
287
+ * [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
288
+ * [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
289
+ * [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog
290
+
252
291
  ## Contributing
253
292
 
254
293
  To run the test suite:
@@ -258,6 +297,24 @@ $ bundle install
258
297
  $ bundle exec rake
259
298
  ```
260
299
 
300
+ To run a single test file, use the `TEST` environment variable:
301
+
302
+ ```bash
303
+ $ TEST=test/test_binder.rb bundle exec rake test
304
+ ```
305
+
306
+ Or use [`m`](https://github.com/qrush/m):
307
+
308
+ ```
309
+ $ bundle exec m test/test_binder.rb
310
+ ```
311
+
312
+ Which can also be used to run a single test case:
313
+
314
+ ```
315
+ $ bundle exec m test/test_binder.rb:37
316
+ ```
317
+
261
318
  ## License
262
319
 
263
320
  Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
data/docs/architecture.md CHANGED
@@ -20,6 +20,7 @@ Clustered mode is shown/discussed here. Single mode is analogous to having a sin
20
20
  * By default, a single, separate thread is used to receive HTTP requests across the socket.
21
21
  * When at least one worker thread is available for work, a connection is accepted and placed in this request buffer
22
22
  * This thread waits for entire HTTP requests to be received over the connection
23
+ * The time spent waiting for the HTTP request body to be received is exposed to the Rack app as `env['puma.request_body_wait']` (milliseconds)
23
24
  * Once received, the connection is pushed into the "todo" set
24
25
  * Worker threads pop work off the "todo" set for processing
25
26
  * The thread processes the request via the rack application (which generates the HTTP response)
data/docs/deployment.md CHANGED
@@ -38,22 +38,42 @@ Here are some rules of thumb:
38
38
  * As you grow more confident in the thread safety of your app, you can tune the
39
39
  workers down and the threads up.
40
40
 
41
+ #### Ubuntu / Systemd (Systemctl) Installation
42
+
43
+ See [systemd.md](systemd.md)
44
+
41
45
  #### Worker utilization
42
46
 
43
- **How do you know if you're got enough (or too many workers)?**
47
+ **How do you know if you've got enough (or too many workers)?**
44
48
 
45
49
  A good question. Due to MRI's GIL, only one thread can be executing Ruby code at a time.
46
50
  But since so many apps are waiting on IO from DBs, etc., they can utilize threads
47
51
  to make better use of the process.
48
52
 
49
53
  The rule of thumb is you never want processes that are pegged all the time. This
50
- means that there is more work to do that the process can get through. On the other
54
+ means that there is more work to do than the process can get through. On the other
51
55
  hand, if you have processes that sit around doing nothing, then they're just eating
52
56
  up resources.
53
57
 
54
- Watching your CPU utilization over time and aim for about 70% on average. This means
58
+ Watch your CPU utilization over time and aim for about 70% on average. This means
55
59
  you've got capacity still but aren't starving threads.
56
60
 
61
+ **Measuring utilization**
62
+
63
+ Using a timestamp header from an upstream proxy server (eg. nginx or haproxy), it's
64
+ possible to get an indication of how long requests have been waiting for a Puma
65
+ thread to become available.
66
+
67
+ * Have your upstream proxy set a header with the time it received the request:
68
+ * nginx: `proxy_set_header X-Request-Start "${msec}";`
69
+ * haproxy: `http-request set-header X-Request-Start "%t";`
70
+ * In your Rack middleware, determine the amount of time elapsed since `X-Request-Start`.
71
+ * To improve accuracy, you will want to subtract time spent waiting for slow clients:
72
+ * `env['puma.request_body_wait']` contains the number of milliseconds Puma spent
73
+ waiting for the client to send the request body.
74
+ * haproxy: `%Th` (TLS handshake time) and `%Ti` (idle time before request) can
75
+ can also be added as headers.
76
+
57
77
  ## Daemonizing
58
78
 
59
79
  I prefer to not daemonize my servers and use something like `runit` or `upstart` to
@@ -62,7 +82,7 @@ makes it easy to figure out what is going on. Additionally, unlike `unicorn`,
62
82
  puma does not require daemonization to do zero-downtime restarts.
63
83
 
64
84
  I see people using daemonization because they start puma directly via capistrano
65
- task and thus want it to live on past the `cap deploy`. To this people I said:
85
+ task and thus want it to live on past the `cap deploy`. To these people I say:
66
86
  You need to be using a process monitor. Nothing is making sure puma stays up in
67
87
  this scenario! You're just waiting for something weird to happen, puma to die,
68
88
  and to get paged at 3am. Do yourself a favor, at least the process monitoring
data/docs/restart.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  To perform a restart, there are 3 builtin mechanisms:
4
4
 
5
- * Send the `puma` process the `SIGUSR2` signal
6
- * Send the `puma` process the `SIGUSR1` signal (rolling restart, cluster mode only)
5
+ * Send the `puma` process the `SIGUSR2` signal (normal restart)
6
+ * Send the `puma` process the `SIGUSR1` signal (restart in phases (a "rolling restart"), cluster mode only)
7
7
  * Use the status server and issue `/restart`
8
8
 
9
9
  No code is shared between the current and restarted process, so it should be safe to issue a restart any place where you would manually stop Puma and start it again.
@@ -22,6 +22,8 @@ But again beware, upgrading an application sometimes involves upgrading the data
22
22
 
23
23
  If you perform a lot of database migrations, you probably should not use phased restart and use a normal/hot restart instead (`pumactl restart`). That way, no code is shared while deploying (in that case, `preload_app!` might help for quicker deployment, see ["Clustered Mode" in the README](../README.md#clustered-mode)).
24
24
 
25
+ **Note**: Hot and phased restarts are only available on MRI, not on JRuby. They are also unavailable on Windows servers.
26
+
25
27
  ### Release Directory
26
28
 
27
29
  If your symlink releases into a common working directory (i.e., `/current` from Capistrano), Puma won't pick up your new changes when running phased restarts without additional configuration. You should set your working directory within Puma's config to specify the directory it should use. This is a change from earlier versions of Puma (< 2.15) that would infer the directory for you.