puma 5.6.5 → 6.1.1

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.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +165 -11
  3. data/README.md +22 -17
  4. data/bin/puma-wild +1 -1
  5. data/docs/compile_options.md +34 -0
  6. data/docs/fork_worker.md +1 -3
  7. data/docs/nginx.md +1 -1
  8. data/docs/systemd.md +1 -2
  9. data/docs/testing_benchmarks_local_files.md +150 -0
  10. data/docs/testing_test_rackup_ci_files.md +36 -0
  11. data/ext/puma_http11/extconf.rb +11 -8
  12. data/ext/puma_http11/http11_parser.c +1 -1
  13. data/ext/puma_http11/http11_parser.h +1 -1
  14. data/ext/puma_http11/http11_parser.java.rl +2 -2
  15. data/ext/puma_http11/http11_parser.rl +2 -2
  16. data/ext/puma_http11/http11_parser_common.rl +2 -2
  17. data/ext/puma_http11/mini_ssl.c +36 -15
  18. data/ext/puma_http11/org/jruby/puma/Http11.java +3 -3
  19. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +1 -1
  20. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +156 -53
  21. data/ext/puma_http11/puma_http11.c +17 -9
  22. data/lib/puma/app/status.rb +3 -3
  23. data/lib/puma/binder.rb +40 -45
  24. data/lib/puma/cli.rb +11 -17
  25. data/lib/puma/client.rb +54 -16
  26. data/lib/puma/cluster/worker.rb +18 -11
  27. data/lib/puma/cluster/worker_handle.rb +4 -1
  28. data/lib/puma/cluster.rb +33 -30
  29. data/lib/puma/configuration.rb +75 -58
  30. data/lib/puma/const.rb +76 -88
  31. data/lib/puma/control_cli.rb +3 -6
  32. data/lib/puma/detect.rb +4 -0
  33. data/lib/puma/dsl.rb +110 -52
  34. data/lib/puma/error_logger.rb +17 -9
  35. data/lib/puma/events.rb +6 -126
  36. data/lib/puma/io_buffer.rb +39 -4
  37. data/lib/puma/jruby_restart.rb +2 -1
  38. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  39. data/lib/puma/launcher.rb +100 -175
  40. data/lib/puma/log_writer.rb +141 -0
  41. data/lib/puma/minissl/context_builder.rb +23 -12
  42. data/lib/puma/minissl.rb +82 -11
  43. data/lib/puma/plugin/systemd.rb +90 -0
  44. data/lib/puma/plugin/tmp_restart.rb +1 -1
  45. data/lib/puma/rack/builder.rb +4 -4
  46. data/lib/puma/rack_default.rb +19 -4
  47. data/lib/puma/reactor.rb +4 -4
  48. data/lib/puma/request.rb +344 -165
  49. data/lib/puma/runner.rb +52 -20
  50. data/lib/puma/sd_notify.rb +149 -0
  51. data/lib/puma/server.rb +57 -71
  52. data/lib/puma/single.rb +13 -11
  53. data/lib/puma/state_file.rb +1 -4
  54. data/lib/puma/thread_pool.rb +16 -16
  55. data/lib/puma/util.rb +0 -11
  56. data/lib/puma.rb +12 -11
  57. data/lib/rack/handler/puma.rb +115 -94
  58. metadata +10 -5
  59. data/lib/puma/queue_close.rb +0 -26
  60. data/lib/puma/systemd.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7be1244aa7c9d74f0021e1763e05b7220ceb3630b41ef7cf2205b71d5f5cf494
4
- data.tar.gz: 802a80a1437d272cfbd101be2fa5370860fd3745b17996661db5eaa47b98b0e1
3
+ metadata.gz: 6a987a441328b2f8be7f7a147af233c0c41b393b98714ed621e2508dc28819d8
4
+ data.tar.gz: bc30afa48b1647abf34f6cf362e3374b76a7e25c605f3ed7e5fd1e7c96dad8fb
5
5
  SHA512:
6
- metadata.gz: f99a9be986d9c7d617b7dbbdae9072e183b7dc957df74f353b110223f1194350a4d87614869aaaae133c737c2ddb12633989850adee14c97e088db830a6e5754
7
- data.tar.gz: 684325223794be8efc7adf39c7eba75bb326bd3646a15aca28ebe92e83b5c836706ca37aeb6c5ec14bb4c9fcdb74ceb8c3b6d146ec862fb5008337c5430b66cc
6
+ metadata.gz: 4a1a05276e82ffd6d012bc75e6f38c2bf30932cb9cd9a6b73a14d783e012f4b942128a72bf0bb8f9bbf8a0062c03d5df234a6baccbc490a2bb64150f480b531f
7
+ data.tar.gz: 6127f2e9b3fd82795696ecd8e0f2016b7252f71d86433087c42c826c7d0d1cc8d2ceda8e4243bf99969d96ba261172e39d59e977ba24d5d75225d7707c64f2a9
data/History.md CHANGED
@@ -1,8 +1,91 @@
1
+ ## 6.1.1 / 2023-02-28
2
+
3
+ * Bugfixes
4
+ * We no longer try to use the systemd plugin for JRuby ([#3079])
5
+ * Allow ::Rack::Handler::Puma.run to work regardless of whether Rack/Rackup are loaded ([#3080])
6
+
7
+ ## 6.1.0 / 2023-02-12
8
+
9
+ * Features
10
+ * WebSocket support via partial hijack ([#3058], [#3007])
11
+ * Add built-in systemd notify support ([#3011])
12
+ * Periodically send status to systemd ([#3006], [#2604])
13
+ * Introduce the ability to return 413: payload too large for requests ([#3040])
14
+ * Log loaded extensions when `PUMA_DEBUG` is set ([#3036], [#3020])
15
+
16
+ * Bugfixes
17
+ * Fix issue with rack 3 compatibility re: rackup ([#3061], [#3057])
18
+ * Allow setting TCP low_latency with SSL listener ([#3065])
19
+
20
+ * Performance
21
+ * Reduce memory usage for large file uploads ([#3062])
22
+
23
+ ## 6.0.2 / 2023-01-01
24
+
25
+ * Refactor
26
+ * Remove use of etc and time gems in Puma ([#3035], [#3033])
27
+ * Refactor const.rb - freeze ([#3016])
28
+
29
+ ## 6.0.1 / 2022-12-20
30
+
31
+ * Bugfixes
32
+ * Handle waking up a closed selector in Reactor#add ([#3005])
33
+ * Fixup response processing, enumerable bodies ([#3004], [#3000])
34
+ * Correctly close app body for all code paths ([#3002], [#2999])
35
+ * Refactor
36
+ * Add IOBuffer to Client, remove from ThreadPool thread instances ([#3013])
37
+
38
+ ## 6.0.0 / 2022-10-14
39
+
40
+ * Breaking Changes
41
+ * Dropping Ruby 2.2 and 2.3 support (now 2.4+) ([#2919])
42
+ * Remote_addr functionality has changed ([#2652], [#2653])
43
+ * No longer supporting Java 1.7 or below (JRuby 9.1 was the last release to support this) ([#2849])
44
+ * Remove nakayoshi GC ([#2933], [#2925])
45
+ * wait_for_less_busy_worker is now default on ([#2940])
46
+ * Prefix all environment variables with `PUMA_` ([#2924], [#2853])
47
+ * Removed some constants ([#2957], [#2958], [#2959], [#2960])
48
+ * The following classes are now part of Puma's private API: `Client`, `Cluster::Worker`, `Cluster::Worker`, `HandleRequest`. ([#2988])
49
+ * Configuration constants like `DefaultRackup` removed ([#2928])
50
+ * Extracted `LogWriter` from `Events` ([#2798])
51
+ * Only accept the standard 8 HTTP methods, others rejected with 501. ([#2932])
52
+
53
+ * Features
54
+ * Increase throughput on large (100kb+) response bodies by 3-10x ([#2896], [#2892])
55
+ * Increase throughput on file responses ([#2923])
56
+ * Add support for streaming bodies in Rack. ([#2740])
57
+ * Allow OpenSSL session reuse via a 'reuse' ssl_bind method or bind string query parameter ([#2845])
58
+ * Allow `run_hooks` to pass a hash to blocks for use later ([#2917], [#2915])
59
+ * Allow using `preload_app!` with `fork_worker` ([#2907])
60
+ * Support request_body_wait metric with higher precision ([#2953])
61
+ * Allow header values to be arrays (Rack 3) ([#2936], [#2931])
62
+ * Export Puma/Ruby versions in /stats ([#2875])
63
+ * Allow configuring request uri max length & request path max length ([#2840])
64
+ * Add a couple of public accessors ([#2774])
65
+ * Log entire backtrace when worker start fails ([#2891])
66
+ * [jruby] Enable TLSv1.3 support ([#2886])
67
+ * [jruby] support setting TLS protocols + rename ssl_cipher_list ([#2899])
68
+ * [jruby] Support a truststore option ([#2849], [#2904], [#2884])
69
+
70
+ * Bugfixes
71
+ * Load the configuration before passing it to the binder ([#2897])
72
+ * Do not raise error raised on HTTP methods we don't recognize or support, like CONNECT ([#2932], [#1441])
73
+ * Fixed a memory leak when creating a new SSL listener ([#2956])
74
+
75
+ * Refactor
76
+ * log_writer.rb - add internal_write method ([#2888])
77
+ * Extract prune_bundler code into it's own class. ([#2797])
78
+ * Refactor Launcher#run to increase readability (no logic change) ([#2795])
79
+ * Ruby 3.2 will have native IO#wait_* methods, don't require io/wait ([#2903])
80
+ * Various internal API refactorings ([#2942], [#2921], [#2922], [#2955])
81
+
1
82
  ## 5.6.5 / 2022-08-23
2
83
 
84
+ * Feature
85
+ * Puma::ControlCLI - allow refork command to be sent as a request ([#2868], [#2866])
86
+
3
87
  * Bugfixes
4
88
  * NullIO#closed should return false ([#2883])
5
- * Puma::ControlCLI - allow refork command to be sent as a request ([#2868], [#2866])
6
89
  * [jruby] Fix TLS verification hang ([#2890], [#2729])
7
90
  * extconf.rb - don't use pkg_config('openssl') if '--with-openssl-dir' is used ([#2885], [#2839])
8
91
  * MiniSSL - detect SSL_CTX_set_dh_auto ([#2864], [#2863])
@@ -318,6 +401,16 @@
318
401
  * Support parallel tests in verbose progress reporting ([#2223])
319
402
  * Refactor error handling in server accept loop ([#2239])
320
403
 
404
+ ## 4.3.12 / 2022-03-30
405
+
406
+ * Security
407
+ * Close several HTTP Request Smuggling exploits (CVE-2022-24790)
408
+
409
+ ## 4.3.11 / 2022-02-11
410
+
411
+ * Security
412
+ * Always close the response body (GHSA-rmj8-8hhh-gv5h)
413
+
321
414
  ## 4.3.10 / 2021-10-12
322
415
 
323
416
  * Bugfixes
@@ -1861,15 +1954,83 @@ be added back in a future date when a java Puma::MiniSSL is added.
1861
1954
  * Bugfixes
1862
1955
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
1863
1956
 
1864
- [#2883]:https://github.com/puma/puma/pull/2883 "PR by @MSP-Greg, merged 2022-06-02"
1957
+ [#3079]:https://github.com/puma/puma/pull/3079 "PR by @mohamedhafez, merged 2023-02-24"
1958
+ [#3080]:https://github.com/puma/puma/pull/3080 "PR by @MSP-Greg, merged 2023-02-16"
1959
+ [#3058]:https://github.com/puma/puma/pull/3058 "PR by @dentarg, merged 2023-01-29"
1960
+ [#3007]:https://github.com/puma/puma/issues/3007 "Issue by @MSP-Greg, closed 2023-01-29"
1961
+ [#3011]:https://github.com/puma/puma/pull/3011 "PR by @joaomarcos96, merged 2023-01-03"
1962
+ [#3006]:https://github.com/puma/puma/pull/3006 "PR by @QWYNG, merged 2023-02-09"
1963
+ [#2604]:https://github.com/puma/puma/issues/2604 "Issue by @dgoetz, closed 2023-02-09"
1964
+ [#3040]:https://github.com/puma/puma/pull/3040 "PR by @shayonj, merged 2023-01-02"
1965
+ [#3036]:https://github.com/puma/puma/pull/3036 "PR by @MSP-Greg, merged 2023-01-13"
1966
+ [#3020]:https://github.com/puma/puma/issues/3020 "Issue by @dentarg, closed 2023-01-13"
1967
+ [#3061]:https://github.com/puma/puma/pull/3061 "PR by @MSP-Greg, merged 2023-02-12"
1968
+ [#3057]:https://github.com/puma/puma/issues/3057 "Issue by @mmarvb8h, closed 2023-02-12"
1969
+ [#3065]:https://github.com/puma/puma/pull/3065 "PR by @MSP-Greg, merged 2023-02-11"
1970
+ [#3062]:https://github.com/puma/puma/pull/3062 "PR by @willkoehler, merged 2023-01-29"
1971
+ [#3035]:https://github.com/puma/puma/pull/3035 "PR by @MSP-Greg, merged 2022-12-24"
1972
+ [#3033]:https://github.com/puma/puma/issues/3033 "Issue by @jules-w2, closed 2022-12-24"
1973
+ [#3016]:https://github.com/puma/puma/pull/3016 "PR by @MSP-Greg, merged 2022-12-24"
1974
+ [#3005]:https://github.com/puma/puma/pull/3005 "PR by @JuanitoFatas, merged 2022-11-04"
1975
+ [#3004]:https://github.com/puma/puma/pull/3004 "PR by @MSP-Greg, merged 2022-11-24"
1976
+ [#3000]:https://github.com/puma/puma/issues/3000 "Issue by @dentarg, closed 2022-11-24"
1977
+ [#3002]:https://github.com/puma/puma/pull/3002 "PR by @MSP-Greg, merged 2022-11-03"
1978
+ [#2999]:https://github.com/puma/puma/issues/2999 "Issue by @aymeric-ledorze, closed 2022-11-03"
1979
+ [#3013]:https://github.com/puma/puma/pull/3013 "PR by @MSP-Greg, merged 2022-11-13"
1980
+ [#2919]:https://github.com/puma/puma/pull/2919 "PR by @MSP-Greg, merged 2022-08-30"
1981
+ [#2652]:https://github.com/puma/puma/issues/2652 "Issue by @Roguelazer, closed 2022-09-04"
1982
+ [#2653]:https://github.com/puma/puma/pull/2653 "PR by @Roguelazer, closed 2022-03-07"
1983
+ [#2849]:https://github.com/puma/puma/pull/2849 "PR by @kares, merged 2022-04-09"
1984
+ [#2933]:https://github.com/puma/puma/pull/2933 "PR by @cafedomancer, merged 2022-09-09"
1985
+ [#2925]:https://github.com/puma/puma/issues/2925 "Issue by @nateberkopec, closed 2022-09-09"
1986
+ [#2940]:https://github.com/puma/puma/pull/2940 "PR by @cafedomancer, merged 2022-09-10"
1987
+ [#2924]:https://github.com/puma/puma/pull/2924 "PR by @cafedomancer, merged 2022-09-07"
1988
+ [#2853]:https://github.com/puma/puma/issues/2853 "Issue by @nateberkopec, closed 2022-09-07"
1989
+ [#2957]:https://github.com/puma/puma/pull/2957 "PR by @JuanitoFatas, merged 2022-09-16"
1990
+ [#2958]:https://github.com/puma/puma/pull/2958 "PR by @JuanitoFatas, merged 2022-09-16"
1991
+ [#2959]:https://github.com/puma/puma/pull/2959 "PR by @JuanitoFatas, merged 2022-09-16"
1992
+ [#2960]:https://github.com/puma/puma/pull/2960 "PR by @JuanitoFatas, merged 2022-09-16"
1993
+ [#2988]:https://github.com/puma/puma/pull/2988 "PR by @MSP-Greg, merged 2022-10-12"
1994
+ [#2928]:https://github.com/puma/puma/pull/2928 "PR by @nateberkopec, merged 2022-09-10"
1995
+ [#2798]:https://github.com/puma/puma/pull/2798 "PR by @johnnyshields, merged 2022-02-05"
1996
+ [#2932]:https://github.com/puma/puma/pull/2932 "PR by @mrzasa, merged 2022-09-12"
1997
+ [#2896]:https://github.com/puma/puma/pull/2896 "PR by @MSP-Greg, merged 2022-09-13"
1998
+ [#2892]:https://github.com/puma/puma/pull/2892 "PR by @guilleiguaran, closed 2022-09-13"
1999
+ [#2923]:https://github.com/puma/puma/pull/2923 "PR by @nateberkopec, merged 2022-09-09"
2000
+ [#2740]:https://github.com/puma/puma/pull/2740 "PR by @ioquatix, merged 2022-01-29"
2001
+ [#2845]:https://github.com/puma/puma/issues/2845 "Issue by @donv, closed 2022-03-22"
2002
+ [#2917]:https://github.com/puma/puma/pull/2917 "PR by @MSP-Greg, merged 2022-09-19"
2003
+ [#2915]:https://github.com/puma/puma/issues/2915 "Issue by @mperham, closed 2022-09-19"
2004
+ [#2907]:https://github.com/puma/puma/pull/2907 "PR by @casperisfine, merged 2022-09-15"
2005
+ [#2953]:https://github.com/puma/puma/pull/2953 "PR by @JuanitoFatas, merged 2022-09-14"
2006
+ [#2936]:https://github.com/puma/puma/pull/2936 "PR by @MSP-Greg, merged 2022-09-09"
2007
+ [#2931]:https://github.com/puma/puma/issues/2931 "Issue by @dentarg, closed 2022-09-09"
2008
+ [#2875]:https://github.com/puma/puma/pull/2875 "PR by @ylecuyer, merged 2022-05-19"
2009
+ [#2840]:https://github.com/puma/puma/pull/2840 "PR by @LukaszMaslej, merged 2022-04-13"
2010
+ [#2774]:https://github.com/puma/puma/pull/2774 "PR by @ob-stripe, merged 2022-01-31"
2011
+ [#2891]:https://github.com/puma/puma/pull/2891 "PR by @gingerlime, merged 2022-06-02"
2012
+ [#2886]:https://github.com/puma/puma/pull/2886 "PR by @kares, merged 2022-05-30"
2013
+ [#2899]:https://github.com/puma/puma/pull/2899 "PR by @kares, merged 2022-07-04"
2014
+ [#2904]:https://github.com/puma/puma/pull/2904 "PR by @kares, merged 2022-08-27"
2015
+ [#2884]:https://github.com/puma/puma/pull/2884 "PR by @kares, merged 2022-05-30"
2016
+ [#2897]:https://github.com/puma/puma/pull/2897 "PR by @Edouard-chin, merged 2022-08-27"
2017
+ [#1441]:https://github.com/puma/puma/issues/1441 "Issue by @nirvdrum, closed 2022-09-12"
2018
+ [#2956]:https://github.com/puma/puma/pull/2956 "PR by @MSP-Greg, merged 2022-09-15"
2019
+ [#2888]:https://github.com/puma/puma/pull/2888 "PR by @MSP-Greg, merged 2022-06-01"
2020
+ [#2797]:https://github.com/puma/puma/pull/2797 "PR by @johnnyshields, merged 2022-02-01"
2021
+ [#2795]:https://github.com/puma/puma/pull/2795 "PR by @johnnyshields, merged 2022-01-31"
2022
+ [#2903]:https://github.com/puma/puma/pull/2903 "PR by @MSP-Greg, merged 2022-08-27"
2023
+ [#2942]:https://github.com/puma/puma/pull/2942 "PR by @nateberkopec, merged 2022-09-15"
2024
+ [#2921]:https://github.com/puma/puma/issues/2921 "Issue by @MSP-Greg, closed 2022-09-15"
2025
+ [#2922]:https://github.com/puma/puma/issues/2922 "Issue by @MSP-Greg, closed 2022-09-10"
2026
+ [#2955]:https://github.com/puma/puma/pull/2955 "PR by @cafedomancer, merged 2022-09-15"
1865
2027
  [#2868]:https://github.com/puma/puma/pull/2868 "PR by @MSP-Greg, merged 2022-06-02"
1866
2028
  [#2866]:https://github.com/puma/puma/issues/2866 "Issue by @slondr, closed 2022-06-02"
1867
- [#2888]:https://github.com/puma/puma/pull/2888 "PR by @MSP-Greg, merged 2022-06-01"
2029
+ [#2883]:https://github.com/puma/puma/pull/2883 "PR by @MSP-Greg, merged 2022-06-02"
1868
2030
  [#2890]:https://github.com/puma/puma/pull/2890 "PR by @kares, merged 2022-06-01"
1869
2031
  [#2729]:https://github.com/puma/puma/issues/2729 "Issue by @kares, closed 2022-06-01"
1870
2032
  [#2885]:https://github.com/puma/puma/pull/2885 "PR by @MSP-Greg, merged 2022-05-30"
1871
2033
  [#2839]:https://github.com/puma/puma/issues/2839 "Issue by @wlipa, closed 2022-05-30"
1872
- [#2882]:https://github.com/puma/puma/pull/2882 "PR by @MSP-Greg, merged 2022-05-19"
1873
2034
  [#2864]:https://github.com/puma/puma/pull/2864 "PR by @MSP-Greg, merged 2022-04-26"
1874
2035
  [#2863]:https://github.com/puma/puma/issues/2863 "Issue by @eradman, closed 2022-04-26"
1875
2036
  [#2861]:https://github.com/puma/puma/pull/2861 "PR by @BlakeWilliams, merged 2022-04-17"
@@ -1880,13 +2041,6 @@ be added back in a future date when a java Puma::MiniSSL is added.
1880
2041
  [#2838]:https://github.com/puma/puma/pull/2838 "PR by @epsilon-0, merged 2022-03-03"
1881
2042
  [#2817]:https://github.com/puma/puma/pull/2817 "PR by @khustochka, merged 2022-02-20"
1882
2043
  [#2810]:https://github.com/puma/puma/pull/2810 "PR by @kzkn, merged 2022-01-27"
1883
- [#2899]:https://github.com/puma/puma/pull/2899 "PR by @kares, merged 2022-07-04"
1884
- [#2891]:https://github.com/puma/puma/pull/2891 "PR by @gingerlime, merged 2022-06-02"
1885
- [#2886]:https://github.com/puma/puma/pull/2886 "PR by @kares, merged 2022-05-30"
1886
- [#2884]:https://github.com/puma/puma/pull/2884 "PR by @kares, merged 2022-05-30"
1887
- [#2875]:https://github.com/puma/puma/pull/2875 "PR by @ylecuyer, merged 2022-05-19"
1888
- [#2840]:https://github.com/puma/puma/pull/2840 "PR by @LukaszMaslej, merged 2022-04-13"
1889
- [#2849]:https://github.com/puma/puma/pull/2849 "PR by @kares, merged 2022-04-09"
1890
2044
  [#2809]:https://github.com/puma/puma/pull/2809 "PR by @dentarg, merged 2022-01-26"
1891
2045
  [#2764]:https://github.com/puma/puma/pull/2764 "PR by @dentarg, merged 2022-01-18"
1892
2046
  [#2708]:https://github.com/puma/puma/issues/2708 "Issue by @erikaxel, closed 2022-01-18"
data/README.md CHANGED
@@ -4,10 +4,8 @@
4
4
 
5
5
  # Puma: A Ruby Web Server Built For Parallelism
6
6
 
7
- [![Actions MRI](https://github.com/puma/puma/workflows/MRI/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3AMRI)
8
- [![Actions non MRI](https://github.com/puma/puma/workflows/non_MRI/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3Anon_MRI)
7
+ [![Actions](https://github.com/puma/puma/workflows/Tests/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3ATests)
9
8
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
10
- [![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)
11
9
  [![StackOverflow](https://img.shields.io/badge/stackoverflow-Puma-blue.svg)]( https://stackoverflow.com/questions/tagged/puma )
12
10
 
13
11
  Puma is a **simple, fast, multi-threaded, and highly parallel HTTP 1.1 server for Ruby/Rack applications**.
@@ -108,15 +106,23 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
108
106
  $ puma -t 8:32 -w 3
109
107
  ```
110
108
 
109
+ Or with the `WEB_CONCURRENCY` environment variable:
110
+
111
+ ```
112
+ $ WEB_CONCURRENCY=3 puma -t 8:32
113
+ ```
114
+
111
115
  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.
112
116
 
113
- 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:
117
+ 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).
118
+
119
+ If the `WEB_CONCURRENCY` environment variable is set to a value > 1 (and `--prune-bundler` has not been specified), preloading will be enabled by default. Otherwise, you can use the `--preload` flag from the command line:
114
120
 
115
121
  ```
116
122
  $ puma -w 3 --preload
117
123
  ```
118
124
 
119
- If you're using a configuration file, use the `preload_app!` method:
125
+ Or, if you're using a configuration file, you can use the `preload_app!` method:
120
126
 
121
127
  ```ruby
122
128
  # config/puma.rb
@@ -124,7 +130,9 @@ workers 3
124
130
  preload_app!
125
131
  ```
126
132
 
127
- Additionally, you can specify a block in your configuration file that will be run on boot of each worker:
133
+ Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preloading copies the code of master into the workers.
134
+
135
+ When using clustered mode, you can specify a block in your configuration file that will be run on boot of each worker:
128
136
 
129
137
  ```ruby
130
138
  # config/puma.rb
@@ -137,12 +145,10 @@ This code can be used to setup the process before booting the application, allow
137
145
  you to do some Puma-specific things that you don't want to embed in your application.
138
146
  For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
139
147
 
140
- Constants loaded by your application (such as `Rails`) will not be available in `on_worker_boot`.
141
- However, these constants _will_ be available if `preload_app!` is enabled, either explicitly in your `puma` config or automatically if
142
- using 2 or more workers in cluster mode.
143
- If `preload_app!` is not enabled and 1 worker is used, then `on_worker_boot` will fire, but your app will not be preloaded and constants will not be available.
148
+ Constants loaded by your application (such as `Rails`) will not be available in `on_worker_boot`
149
+ unless preloading is enabled.
144
150
 
145
- `before_fork` specifies a block to be run before workers are forked:
151
+ You can also specify a block to be run before workers are forked, using `before_fork`:
146
152
 
147
153
  ```ruby
148
154
  # config/puma.rb
@@ -151,8 +157,6 @@ before_fork do
151
157
  end
152
158
  ```
153
159
 
154
- 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.
155
-
156
160
  ### Error handling
157
161
 
158
162
  If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
@@ -192,15 +196,15 @@ Need a bit of security? Use SSL sockets:
192
196
  ```
193
197
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
194
198
  ```
195
- #### Self-signed SSL certificates (via the [`localhost`] gem, for development use):
199
+ #### Self-signed SSL certificates (via the [`localhost`] gem, for development use):
196
200
 
197
- Puma supports the [`localhost`] gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, the integration can only be used in MRI.
201
+ Puma supports the [`localhost`] gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, the integration can only be used in MRI.
198
202
 
199
203
  Puma automatically configures SSL when the [`localhost`] gem is loaded in a `development` environment:
200
204
 
201
205
  ```ruby
202
206
  # Add the gem to your Gemfile
203
- group(:development) do
207
+ group(:development) do
204
208
  gem 'localhost'
205
209
  end
206
210
 
@@ -350,7 +354,7 @@ reliability in production environments:
350
354
  * [rc.d](docs/jungle/rc.d/README.md)
351
355
  * [systemd](docs/systemd.md)
352
356
 
353
- Community guides:
357
+ Community guides:
354
358
 
355
359
  * [Deploying Puma on OpenBSD using relayd and httpd](https://gist.github.com/anon987654321/4532cf8d6c59c1f43ec8973faa031103)
356
360
 
@@ -361,6 +365,7 @@ Community guides:
361
365
  * [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
362
366
  * [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
363
367
  * [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog
368
+ * [puma-plugin-telemetry](https://github.com/babbel/puma-plugin-telemetry) - telemetry plugin for Puma offering various targets to publish
364
369
 
365
370
  ### Monitoring
366
371
 
data/bin/puma-wild CHANGED
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  module Puma; end
18
18
 
19
- Puma.const_set("WILD_ARGS", ["-I", inc])
19
+ Puma.const_set(:WILD_ARGS, ["-I", inc])
20
20
 
21
21
  require 'puma/cli'
22
22
 
@@ -19,3 +19,37 @@ For Bundler, use its configuration system:
19
19
  ```
20
20
  bundle config build.puma "--with-cflags='-D PUMA_QUERY_STRING_MAX_LENGTH=64000'"
21
21
  ```
22
+
23
+ ## Request Path, `PUMA_REQUEST_PATH_MAX_LENGTH`
24
+
25
+ By default, the max length of `REQUEST_PATH` is `8192`. But you may want to
26
+ adjust it to accept longer paths in requests.
27
+
28
+ For manual install, pass the `PUMA_REQUEST_PATH_MAX_LENGTH` option like this:
29
+
30
+ ```
31
+ gem install puma -- --with-cflags="-D PUMA_REQUEST_PATH_MAX_LENGTH=64000"
32
+ ```
33
+
34
+ For Bundler, use its configuration system:
35
+
36
+ ```
37
+ bundle config build.puma "--with-cflags='-D PUMA_REQUEST_PATH_MAX_LENGTH=64000'"
38
+ ```
39
+
40
+ ## Request URI, `PUMA_REQUEST_URI_MAX_LENGTH`
41
+
42
+ By default, the max length of `REQUEST_URI` is `1024 * 12`. But you may want to
43
+ adjust it to accept longer URIs in requests.
44
+
45
+ For manual install, pass the `PUMA_REQUEST_URI_MAX_LENGTH` option like this:
46
+
47
+ ```
48
+ gem install puma -- --with-cflags="-D PUMA_REQUEST_URI_MAX_LENGTH=64000"
49
+ ```
50
+
51
+ For Bundler, use its configuration system:
52
+
53
+ ```
54
+ bundle config build.puma "--with-cflags='-D PUMA_REQUEST_URI_MAX_LENGTH=64000'"
55
+ ```
data/docs/fork_worker.md CHANGED
@@ -10,7 +10,7 @@ Puma 5 introduces an experimental new cluster-mode configuration option, `fork_w
10
10
  10004 \_ puma: cluster worker 3: 10000 [puma]
11
11
  ```
12
12
 
13
- Similar to the `preload_app!` option, the `fork_worker` option allows your application to be initialized only once for copy-on-write memory savings, and it has two additional advantages:
13
+ The `fork_worker` option allows your application to be initialized only once for copy-on-write memory savings, and it has two additional advantages:
14
14
 
15
15
  1. **Compatible with phased restart.** Because the master process itself doesn't preload the application, this mode works with phased restart (`SIGUSR1` or `pumactl phased-restart`). When worker 0 reloads as part of a phased restart, it initializes a new copy of your application first, then the other workers reload by forking from this new worker already containing the new preloaded application.
16
16
 
@@ -24,8 +24,6 @@ Similar to the `preload_app!` option, the `fork_worker` option allows your appli
24
24
 
25
25
  ### Limitations
26
26
 
27
- - Not compatible with the `preload_app!` option
28
-
29
27
  - This mode is still very experimental so there may be bugs or edge-cases, particularly around expected behavior of existing hooks. Please open a [bug report](https://github.com/puma/puma/issues/new?template=bug_report.md) if you encounter any issues.
30
28
 
31
29
  - In order to fork new workers cleanly, worker 0 shuts down its server and stops serving requests so there are no open file descriptors or other kinds of shared global state between processes, and to maximize copy-on-write efficiency across the newly-forked workers. This may temporarily reduce total capacity of the cluster during a phased restart / refork.
data/docs/nginx.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is a very common setup using an upstream. It was adapted from some Capistrano recipe I found on the Internet a while ago.
4
4
 
5
- ```
5
+ ```nginx
6
6
  upstream myapp {
7
7
  server unix:///myapp/tmp/puma.sock;
8
8
  }
data/docs/systemd.md CHANGED
@@ -24,8 +24,7 @@ After=network.target
24
24
 
25
25
  [Service]
26
26
  # Puma supports systemd's `Type=notify` and watchdog service
27
- # monitoring, if the [sd_notify](https://github.com/agis/ruby-sdnotify) gem is installed,
28
- # as of Puma 5.1 or later.
27
+ # monitoring, as of Puma 5.1 or later.
29
28
  # On earlier versions of Puma or JRuby, change this to `Type=simple` and remove
30
29
  # the `WatchdogSec` line.
31
30
  Type=notify
@@ -0,0 +1,150 @@
1
+ # Testing - benchmark/local files
2
+
3
+ These files generate data that shows request-per-second (RPS), etc. Typically, files are in
4
+ pairs, a shell script and a Ruby script. The shell script starts the server, then runs the
5
+ Ruby file, which starts client request stream(s), then collects and logs metrics.
6
+
7
+ ## response_time_wrk.sh
8
+
9
+ This uses [wrk] for generating data. One or more wrk runs are performed. Summarizes RPS and
10
+ wrk latency times. The default for the `-b` argument runs 28 different client request streams,
11
+ and takes a bit over 5 minutes. See 'Request Stream Configuration' below for `-b` argument
12
+ description.
13
+
14
+ <details>
15
+ <summary>Summary output for<br/><code>benchmarks/local/response_time_wrk.sh -w2 -t5:5 -s tcp6</code>:</summary>
16
+
17
+ ```
18
+ Type req/sec 50% 75% 90% 99% 100% Resp Size
19
+ ───────────────────────────────────────────────────────────────── 1kB
20
+ array 13710 0.74 2.52 5.23 7.76 37.45 1024
21
+ chunk 13502 0.76 2.55 5.28 7.84 11.23 1042
22
+ string 13794 0.74 2.51 5.20 7.75 14.07 1024
23
+ io 9615 1.16 3.45 7.13 10.57 15.75 1024
24
+ ───────────────────────────────────────────────────────────────── 10kB
25
+ array 13458 0.76 2.57 5.31 7.93 13.94 10239
26
+ chunk 13066 0.78 2.64 5.46 8.18 38.48 10320
27
+ string 13500 0.76 2.55 5.29 7.88 11.42 10240
28
+ io 9293 1.18 3.59 7.39 10.94 16.99 10240
29
+ ───────────────────────────────────────────────────────────────── 100kB
30
+ array 11315 0.96 3.06 6.33 9.49 17.69 102424
31
+ chunk 9916 1.10 3.48 7.20 10.73 15.14 103075
32
+ string 10948 1.00 3.17 6.57 9.83 17.88 102378
33
+ io 8901 1.21 3.72 7.48 11.27 59.98 102407
34
+ ───────────────────────────────────────────────────────────────── 256kB
35
+ array 9217 1.15 3.82 7.88 11.74 17.12 262212
36
+ chunk 7339 1.45 4.76 9.81 14.63 22.70 264007
37
+ string 8574 1.19 3.81 7.73 11.21 15.80 262147
38
+ io 8911 1.19 3.80 7.55 15.25 60.01 262183
39
+ ───────────────────────────────────────────────────────────────── 512kB
40
+ array 6951 1.49 5.03 10.28 15.90 25.08 524378
41
+ chunk 5234 2.03 6.56 13.57 20.46 32.15 527862
42
+ string 6438 1.55 5.04 10.12 16.28 72.87 524275
43
+ io 8533 1.15 4.62 8.79 48.15 70.51 524327
44
+ ───────────────────────────────────────────────────────────────── 1024kB
45
+ array 4122 1.80 15.59 41.87 67.79 121.00 1048565
46
+ chunk 3158 2.82 15.22 31.00 71.39 99.90 1055654
47
+ string 4710 2.24 6.66 13.65 20.38 70.44 1048575
48
+ io 8355 1.23 3.95 7.94 14.08 68.54 1048498
49
+ ───────────────────────────────────────────────────────────────── 2048kB
50
+ array 2454 4.12 14.02 27.70 43.48 88.89 2097415
51
+ chunk 1743 6.26 17.65 36.98 55.78 92.10 2111358
52
+ string 2479 4.38 12.52 25.65 38.44 95.62 2097502
53
+ io 8264 1.25 3.83 7.76 11.73 65.69 2097090
54
+
55
+ Body ────────── req/sec ────────── ─────── req 50% times ───────
56
+ KB array chunk string io array chunk string io
57
+ 1 13710 13502 13794 9615 0.745 0.757 0.741 1.160
58
+ 10 13458 13066 13500 9293 0.760 0.784 0.759 1.180
59
+ 100 11315 9916 10948 8901 0.960 1.100 1.000 1.210
60
+ 256 9217 7339 8574 8911 1.150 1.450 1.190 1.190
61
+ 512 6951 5234 6438 8533 1.490 2.030 1.550 1.150
62
+ 1024 4122 3158 4710 8355 1.800 2.820 2.240 1.230
63
+ 2048 2454 1743 2479 8264 4.120 6.260 4.380 1.250
64
+ ─────────────────────────────────────────────────────────────────────
65
+ wrk -t8 -c16 -d10s
66
+ benchmarks/local/response_time_wrk.sh -w2 -t5:5 -s tcp6 -Y
67
+ Server cluster mode -w2 -t5:5, bind: tcp6
68
+ Puma repo branch 00-response-refactor
69
+ ruby 3.2.0dev (2022-06-14T01:21:55Z master 048f14221c) +YJIT [x86_64-linux]
70
+
71
+ [2136] - Gracefully shutting down workers...
72
+ [2136] === puma shutdown: 2022-06-13 21:16:13 -0500 ===
73
+ [2136] - Goodbye!
74
+
75
+ 5:15 Total Time
76
+ ```
77
+ </details><br/>
78
+
79
+ ## bench_base.sh, bench_base.rb
80
+
81
+ These two files setup parameters for the Puma server, which is normally started in a shell
82
+ script. It then starts a Ruby file (a subclass of BenchBase), passing arguments to it. The
83
+ Ruby file is normally used to generate a client request stream(s).
84
+
85
+ ### Puma Configuration
86
+
87
+ The following arguments are used for the Puma server:
88
+
89
+ * **`-C`** - configuration file
90
+ * **`-d`** - app delay
91
+ * **`-r`** - rackup file, often defaults to test/rackup/ci_select.ru
92
+ * **`-s`** - bind socket type, default is tcp/tcp4, also tcp6, ssl/ssl4, ssl6, unix, or aunix
93
+ (unix & abstract unix are not available with wrk).
94
+ * **`-t`** - threads, expressed as '5:5', same as Puma --thread
95
+ * **`-w`** - workers, same as Puma --worker
96
+ * **`-Y`** - enable Ruby YJIT
97
+
98
+ ### Request Stream Configuration
99
+
100
+ The following arguments are used for request streams:
101
+
102
+ * **`-b`** - response body configuration. Body type options are a array, c chunked, s string,
103
+ and i for File/IO. None or any combination can be specified, they should start the option.
104
+ Then, any combination of comma separated integers can be used for the response body size
105
+ in kB. The string 'ac50,100' would create four runs, 50kb array, 50kB chunked, 100kB array,
106
+ and 100kB chunked. See 'Testing - test/rackup/ci-*.ru files' for more info.
107
+ * **`-c`** - connections per client request stream thread, defaults to 2 for wrk.
108
+ * **`-D`** - duration of client request stream in seconds.
109
+ * **`-T`** - number of threads in the client request stream. For wrk, this defaults to
110
+ 80% of Puma workers * max_threads.
111
+
112
+ ### Notes - Configuration
113
+
114
+ The above lists script arguments.
115
+
116
+ `bench_base.sh` contains most server defaults. Many can be set via ENV variables.
117
+
118
+ `bench_base.rb` contains the client request stream defaults. The default value for
119
+ `-b` is `acsi1,10,100,256,512,1024,2048`, which is a 4 x 7 matrix, and hence, runs
120
+ 28 jobs. Also, the i body type (File/IO) generates files, they are placed in the
121
+ `"#{Dir.tmpdir}/.puma_response_body_io"` directory, which is created.
122
+
123
+ ### Notes - wrk
124
+
125
+ The shell scripts use `-T` for wrk's thread count, since `-t` is used for Puma
126
+ server threads. Regarding the `-c` argument, wrk has an interesting behavior.
127
+ The total number of connections is set by `(connections/threads).to_i`. The scripts
128
+ here use `-c` as connections per thread. Hence, using `-T4 -c2` will yield a total
129
+ of eight wrk connections, two per thread. The equivalent wrk arguments would be `-t4 -c8`.
130
+
131
+ Puma can only process so many requests, and requests will queue in the backlog
132
+ until Puma can respond to them. With wrk, if the number of total connections is
133
+ too high, one will see the upper latency times increase, pushing into the lower
134
+ latency times as the connections are increased. The default values for wrk's
135
+ threads and connections were chosen to minimize requests' time in the backlog.
136
+
137
+ An example with four wrk runs using `-b s10`. Notice that `req/sec` varies by
138
+ less than 1%, but the `75%` times increase by an order of magnitude:
139
+ ```
140
+ req/sec 50% 75% 90% 99% 100% Resp Size wrk cmd line
141
+ ─────────────────────────────────────────────────────────────────────────────
142
+ 13597 0.755 2.550 5.260 7.800 13.310 12040 wrk -t8 -c16 -d10
143
+ 13549 0.793 4.430 8.140 11.220 16.600 12002 wrk -t10 -c20 -d10
144
+ 13570 1.040 25.790 40.010 49.070 58.300 11982 wrk -t8 -c64 -d10
145
+ 13684 1.050 25.820 40.080 49.160 66.190 12033 wrk -t16 -c64 -d10
146
+ ```
147
+ Finally, wrk's output may cause rounding errors, so the response body size calculation is
148
+ imprecise.
149
+
150
+ [wrk]: <https://github.com/ioquatix/wrk>
@@ -0,0 +1,36 @@
1
+ # Testing - test/rackup/ci-*.ru files
2
+
3
+ ## Overview
4
+
5
+ Puma should efficiently handle a variety of response bodies, varying both by size
6
+ and by the type of object used for the body.
7
+
8
+ Five rackup files are located in 'test/rackup' that can be used. All have their
9
+ request body size (in kB) set via `Body-Conf` header or with `ENV['CI_BODY_CONF']`.
10
+ Additionally, the ci_select.ru file can have it's body type set via a starting
11
+ character.
12
+
13
+ * **ci_array.ru** - body is an `Array` of 1kB strings. `Content-Length` is not set.
14
+ * **ci_chunked.ru** - body is an `Enumerator` of 1kB strings. `Content-Length` is not set.
15
+ * **ci_io.ru** - body is a File/IO object. `Content-Length` is set.
16
+ * **ci_string.ru** - body is a single string. `Content-Length` is set.
17
+ * **ci_select.ru** - can be any of the above.
18
+
19
+ All responses have 25 headers, total length approx 1kB. ci_array.ru and ci_chunked.ru
20
+ contain 1kB items.
21
+
22
+ All can be delayed by a float value (seconds) specified by the `Dly` header
23
+
24
+ Note that rhe `Body-Conf` header takes precedence, and `ENV['CI_BODY_CONF']` is
25
+ only read on load.
26
+
27
+ ## ci_select.ru
28
+
29
+ The ci_select.ru file allows a starting character to specify the body type in the
30
+ `Body-Conf` header or with `ENV['CI_BODY_CONF']`.
31
+ * **a** - array of strings
32
+ * **c** - chunked (enum)
33
+ * **s** - single string
34
+ * **i** - File/IO
35
+
36
+ A value of `a100` would return a body as an array of 100 1kB strings.