unicorn 4.9.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitattributes +5 -0
- data/.olddoc.yml +13 -6
- data/Application_Timeouts +7 -7
- data/DESIGN +2 -4
- data/Documentation/.gitignore +1 -3
- data/Documentation/unicorn.1 +222 -0
- data/Documentation/unicorn_rails.1 +207 -0
- data/FAQ +17 -8
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +121 -56
- data/HACKING +1 -2
- data/ISSUES +40 -41
- data/KNOWN_ISSUES +11 -11
- data/LICENSE +2 -2
- data/Links +24 -25
- data/PHILOSOPHY +0 -6
- data/README +46 -39
- data/SIGNALS +2 -2
- data/Sandbox +10 -9
- data/TODO +0 -2
- data/TUNING +30 -9
- data/archive/slrnpull.conf +1 -1
- data/bin/unicorn +4 -2
- data/bin/unicorn_rails +3 -3
- data/examples/big_app_gc.rb +1 -1
- data/examples/init.sh +36 -8
- data/examples/logrotate.conf +17 -2
- data/examples/nginx.conf +14 -14
- data/examples/unicorn.conf.minimal.rb +2 -2
- data/examples/unicorn.conf.rb +3 -6
- data/examples/unicorn.socket +11 -0
- data/examples/unicorn@.service +40 -0
- data/ext/unicorn_http/common_field_optimization.h +23 -5
- data/ext/unicorn_http/ext_help.h +0 -20
- data/ext/unicorn_http/extconf.rb +37 -1
- data/ext/unicorn_http/global_variables.h +1 -1
- data/ext/unicorn_http/httpdate.c +2 -2
- data/ext/unicorn_http/unicorn_http.rl +167 -170
- data/ext/unicorn_http/unicorn_http_common.rl +1 -1
- data/lib/unicorn.rb +66 -46
- data/lib/unicorn/configurator.rb +110 -44
- data/lib/unicorn/const.rb +2 -25
- data/lib/unicorn/http_request.rb +110 -31
- data/lib/unicorn/http_response.rb +17 -31
- data/lib/unicorn/http_server.rb +238 -157
- data/lib/unicorn/launcher.rb +1 -1
- data/lib/unicorn/oob_gc.rb +6 -6
- data/lib/unicorn/socket_helper.rb +58 -78
- data/lib/unicorn/stream_input.rb +8 -7
- data/lib/unicorn/tee_input.rb +8 -10
- data/lib/unicorn/tmpio.rb +8 -7
- data/lib/unicorn/util.rb +5 -4
- data/lib/unicorn/worker.rb +36 -23
- data/t/GNUmakefile +3 -72
- data/t/README +4 -4
- data/t/t0011-active-unix-socket.sh +1 -1
- data/t/t0012-reload-empty-config.sh +2 -1
- data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
- data/t/t0301.ru +13 -0
- data/t/test-lib.sh +2 -2
- data/test/benchmark/README +14 -4
- data/test/benchmark/ddstream.ru +50 -0
- data/test/benchmark/readinput.ru +40 -0
- data/test/benchmark/uconnect.perl +66 -0
- data/test/exec/test_exec.rb +73 -19
- data/test/test_helper.rb +40 -31
- data/test/unit/test_ccc.rb +91 -0
- data/test/unit/test_droplet.rb +1 -1
- data/test/unit/test_http_parser.rb +46 -16
- data/test/unit/test_http_parser_ng.rb +97 -114
- data/test/unit/test_request.rb +10 -10
- data/test/unit/test_response.rb +28 -16
- data/test/unit/test_server.rb +86 -12
- data/test/unit/test_signals.rb +8 -8
- data/test/unit/test_socket_helper.rb +14 -10
- data/test/unit/test_upload.rb +9 -14
- data/test/unit/test_util.rb +27 -2
- data/unicorn.gemspec +27 -19
- metadata +24 -45
- data/Documentation/GNUmakefile +0 -30
- data/Documentation/unicorn.1.txt +0 -185
- data/Documentation/unicorn_rails.1.txt +0 -175
- data/examples/git.ru +0 -13
- data/lib/unicorn/app/exec_cgi.rb +0 -154
- data/lib/unicorn/app/inetd.rb +0 -109
- data/lib/unicorn/ssl_client.rb +0 -11
- data/lib/unicorn/ssl_configurator.rb +0 -104
- data/lib/unicorn/ssl_server.rb +0 -42
- data/t/hijack.ru +0 -42
- data/t/t0016-trust-x-forwarded-false.sh +0 -30
- data/t/t0017-trust-x-forwarded-true.sh +0 -30
- data/t/t0200-rack-hijack.sh +0 -27
- data/test/unit/test_http_parser_xftrust.rb +0 -38
- data/test/unit/test_sni_hostnames.rb +0 -47
data/KNOWN_ISSUES
CHANGED
@@ -9,11 +9,11 @@ acceptable solution. Those issues are documented here.
|
|
9
9
|
handlers.
|
10
10
|
|
11
11
|
* Issues with FreeBSD jails can be worked around as documented by Tatsuya Ono:
|
12
|
-
|
12
|
+
https://yhbt.net/unicorn-public/CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q@mail.gmail.com/
|
13
13
|
|
14
14
|
* PRNGs (pseudo-random number generators) loaded before forking
|
15
15
|
(e.g. "preload_app true") may need to have their internal state
|
16
|
-
reset in the after_fork hook. Starting with
|
16
|
+
reset in the after_fork hook. Starting with unicorn 3.6.1, we
|
17
17
|
have builtin workarounds for Kernel#rand and OpenSSL::Random users,
|
18
18
|
but applications may use other PRNGs.
|
19
19
|
|
@@ -36,31 +36,31 @@ acceptable solution. Those issues are documented here.
|
|
36
36
|
|
37
37
|
* Under some versions of Ruby 1.8, it is necessary to call +srand+ in an
|
38
38
|
after_fork hook to get correct random number generation. We have a builtin
|
39
|
-
workaround for this starting with
|
39
|
+
workaround for this starting with unicorn 3.6.1
|
40
40
|
|
41
|
-
See http://
|
41
|
+
See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/36450
|
42
42
|
|
43
43
|
* On Ruby 1.8 prior to Ruby 1.8.7-p248, *BSD platforms have a broken
|
44
44
|
stdio that causes failure for file uploads larger than 112K. Upgrade
|
45
|
-
your version of Ruby or continue using
|
45
|
+
your version of Ruby or continue using unicorn 1.x/3.4.x.
|
46
46
|
|
47
47
|
* Under Ruby 1.9.1, methods like Array#shuffle and Array#sample will
|
48
48
|
segfault if called after forking. Upgrade to Ruby 1.9.2 or call
|
49
49
|
"Kernel.rand" in your after_fork hook to reinitialize the random
|
50
50
|
number generator.
|
51
51
|
|
52
|
-
See http://
|
52
|
+
See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/28655
|
53
53
|
|
54
54
|
* Rails 2.3.2 bundles its own version of Rack. This may cause subtle
|
55
55
|
bugs when simultaneously loaded with the system-wide Rack Rubygem
|
56
|
-
which
|
56
|
+
which unicorn depends on. Upgrading to Rails 2.3.4 (or later) is
|
57
57
|
strongly recommended for all Rails 2.3.x users for this (and security
|
58
58
|
reasons). Rails 2.2.x series (or before) did not bundle Rack and are
|
59
59
|
should be unnaffected. If there is any reason which forces your
|
60
60
|
application to use Rails 2.3.2 and you have no other choice, then
|
61
|
-
you may edit your
|
61
|
+
you may edit your unicorn gemspec and remove the Rack dependency.
|
62
62
|
|
63
|
-
ref:
|
63
|
+
ref: https://yhbt.net/unicorn-public/20091014221552.GA30624@dcvr.yhbt.net/
|
64
64
|
Note: the workaround described in the article above only made
|
65
65
|
the issue more subtle and we didn't notice them immediately.
|
66
66
|
|
@@ -71,9 +71,9 @@ acceptable solution. Those issues are documented here.
|
|
71
71
|
set :env, :production
|
72
72
|
set :run, false
|
73
73
|
Since this is no longer an issue with Sinatra 0.9.x apps, this will not be
|
74
|
-
fixed on our end. Since
|
74
|
+
fixed on our end. Since unicorn is itself the application launcher, the
|
75
75
|
at_exit handler used in old Sinatra always caused Mongrel to be launched
|
76
|
-
whenever a
|
76
|
+
whenever a unicorn worker was about to exit.
|
77
77
|
|
78
78
|
Also remember we're capable of replacing the running binary without dropping
|
79
79
|
any connections regardless of framework :)
|
data/LICENSE
CHANGED
@@ -8,8 +8,8 @@ any later version. We currently prefer the GPLv3 or later for
|
|
8
8
|
derivative works, but the GPLv2 is fine.
|
9
9
|
|
10
10
|
The complete texts of the GPLv2 and GPLv3 are below:
|
11
|
-
GPLv2 -
|
12
|
-
GPLv3 -
|
11
|
+
GPLv2 - https://www.gnu.org/licenses/gpl-2.0.txt
|
12
|
+
GPLv3 - https://www.gnu.org/licenses/gpl-3.0.txt
|
13
13
|
|
14
14
|
You may (against our _preference_) also use the Ruby 1.8 license terms
|
15
15
|
which we inherited from the original Mongrel project when we forked it:
|
data/Links
CHANGED
@@ -1,59 +1,58 @@
|
|
1
1
|
= Related Projects
|
2
2
|
|
3
|
-
If you're interested in
|
3
|
+
If you're interested in unicorn, you may be interested in some of the projects
|
4
4
|
listed below. If you have any links to add/change/remove, please tell us at
|
5
|
-
mailto:unicorn-public@
|
5
|
+
mailto:unicorn-public@yhbt.net!
|
6
6
|
|
7
7
|
== Disclaimer
|
8
8
|
|
9
|
-
The
|
10
|
-
Furthermore, the
|
9
|
+
The unicorn project is not responsible for the content in these links.
|
10
|
+
Furthermore, the unicorn project has never, does not and will never endorse:
|
11
11
|
|
12
12
|
* any for-profit entities or services
|
13
|
-
* any non-{Free Software}[
|
13
|
+
* any non-{Free Software}[https://www.gnu.org/philosophy/free-sw.html]
|
14
14
|
|
15
15
|
The existence of these links does not imply endorsement of any entities
|
16
16
|
or services behind them.
|
17
17
|
|
18
|
-
=== For use with
|
18
|
+
=== For use with unicorn
|
19
19
|
|
20
20
|
* {Bluepill}[https://github.com/arya/bluepill] -
|
21
21
|
a simple process monitoring tool written in Ruby
|
22
22
|
|
23
23
|
* {golden_brindle}[https://github.com/simonoff/golden_brindle] - tool to
|
24
|
-
manage multiple
|
24
|
+
manage multiple unicorn instances/applications on a single server
|
25
25
|
|
26
|
-
* {raindrops}[
|
26
|
+
* {raindrops}[https://yhbt.net/raindrops/] - real-time stats for
|
27
27
|
preforking Rack servers
|
28
28
|
|
29
|
-
* {UnXF}[
|
29
|
+
* {UnXF}[https://yhbt.net/unxf/] Un-X-Forward* the Rack environment,
|
30
30
|
useful since unicorn is designed to be deployed behind a reverse proxy.
|
31
31
|
|
32
|
-
===
|
32
|
+
=== unicorn is written to work with
|
33
33
|
|
34
|
-
* {Rack}[
|
34
|
+
* {Rack}[https://rack.github.io/] - a minimal interface between webservers
|
35
35
|
supporting Ruby and Ruby frameworks
|
36
36
|
|
37
|
-
* {Ruby}[
|
37
|
+
* {Ruby}[https://www.ruby-lang.org/en/] - the programming language of
|
38
|
+
Rack and unicorn
|
38
39
|
|
39
|
-
* {nginx}[
|
40
|
-
|
41
|
-
* {kgio}[http://bogomips.org/kgio/] - the I/O library written for \Unicorn
|
40
|
+
* {nginx}[https://nginx.org/] (Free versions) -
|
41
|
+
the reverse proxy for use with unicorn
|
42
42
|
|
43
43
|
=== Derivatives
|
44
44
|
|
45
|
-
* {Green Unicorn}[
|
46
|
-
|
47
|
-
* {Rainbows!}[http://rainbows.bogomips.org/] - \Unicorn for sleepy
|
48
|
-
apps and slow clients (historical).
|
45
|
+
* {Green Unicorn}[https://gunicorn.org/] - a Python version of unicorn
|
49
46
|
|
50
|
-
* {
|
51
|
-
|
47
|
+
* {Starman}[https://metacpan.org/release/Starman/] - Plack/PSGI version
|
48
|
+
of unicorn
|
52
49
|
|
53
50
|
=== Prior Work
|
54
51
|
|
55
|
-
* {Mongrel}[
|
56
|
-
unicorn is based on
|
52
|
+
* {Mongrel}[https://rubygems.org/gems/mongrel] - the awesome webserver
|
53
|
+
unicorn is based on. A historical archive of the mongrel dev list
|
54
|
+
featuring early discussions of unicorn is available at:
|
55
|
+
https://yhbt.net/mongrel-devel/
|
57
56
|
|
58
|
-
* {david}[
|
59
|
-
nginx in front of
|
57
|
+
* {david}[https://yhbt.net/david.git] - a tool to explain why you need
|
58
|
+
nginx in front of unicorn
|
data/PHILOSOPHY
CHANGED
@@ -137,9 +137,3 @@ unicorn is highly inefficient for Comet/reverse-HTTP/push applications
|
|
137
137
|
where the HTTP connection spends a large amount of time idle.
|
138
138
|
Nevertheless, the ease of troubleshooting, debugging, and management of
|
139
139
|
unicorn may still outweigh the drawbacks for these applications.
|
140
|
-
|
141
|
-
The {Rainbows!}[http://rainbows.bogomips.org/] aims to fill the gap for
|
142
|
-
odd corner cases where the nginx + unicorn combination is not enough.
|
143
|
-
While Rainbows! management/administration is largely identical to
|
144
|
-
unicorn, Rainbows! is far more ambitious and has seen little real-world
|
145
|
-
usage.
|
data/README
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
=
|
1
|
+
= unicorn: Rack HTTP server for fast clients and Unix
|
2
2
|
|
3
|
-
|
3
|
+
unicorn is an HTTP server for Rack applications designed to only serve
|
4
4
|
fast clients on low-latency, high-bandwidth connections and take
|
5
5
|
advantage of features in Unix/Unix-like kernels. Slow clients should
|
6
6
|
only be served by placing a reverse proxy capable of fully buffering
|
7
|
-
both the the request and response in between
|
7
|
+
both the the request and response in between unicorn and slow clients.
|
8
8
|
|
9
9
|
== Features
|
10
10
|
|
11
11
|
* Designed for Rack, Unix, fast clients, and ease-of-debugging. We
|
12
12
|
cut out everything that is better supported by the operating system,
|
13
|
-
{nginx}[
|
13
|
+
{nginx}[https://nginx.org/] or {Rack}[https://rack.github.io/].
|
14
14
|
|
15
15
|
* Compatible with Ruby 1.9.3 and later.
|
16
|
-
unicorn 4.
|
16
|
+
unicorn 4.x remains supported for Ruby 1.8 users.
|
17
17
|
|
18
|
-
* Process management:
|
18
|
+
* Process management: unicorn will reap and restart workers that
|
19
19
|
die from broken apps. There is no need to manage multiple processes
|
20
|
-
or ports yourself.
|
20
|
+
or ports yourself. unicorn can spawn and manage any number of
|
21
21
|
worker processes you choose to scale to your backend.
|
22
22
|
|
23
23
|
* Load balancing is done entirely by the operating system kernel.
|
@@ -27,25 +27,25 @@ both the the request and response in between \Unicorn and slow clients.
|
|
27
27
|
all run within their own isolated address space and only serve one
|
28
28
|
client at a time for maximum robustness.
|
29
29
|
|
30
|
-
* Supports all Rack applications, along with pre-Rack versions of
|
31
|
-
Ruby on Rails via a Rack wrapper.
|
32
|
-
|
33
30
|
* Builtin reopening of all log files in your application via
|
34
31
|
USR1 signal. This allows logrotate to rotate files atomically and
|
35
32
|
quickly via rename instead of the racy and slow copytruncate method.
|
36
|
-
|
33
|
+
unicorn also takes steps to ensure multi-line log entries from one
|
37
34
|
request all stay within the same file.
|
38
35
|
|
39
36
|
* nginx-style binary upgrades without losing connections.
|
40
|
-
You can upgrade
|
37
|
+
You can upgrade unicorn, your entire application, libraries
|
41
38
|
and even your Ruby interpreter without dropping clients.
|
42
39
|
|
40
|
+
* transparent upgrades using systemd socket activation is
|
41
|
+
supported since unicorn 5.0
|
42
|
+
|
43
43
|
* before_fork and after_fork hooks in case your application
|
44
44
|
has special needs when dealing with forked processes. These
|
45
45
|
should not be needed when the "preload_app" directive is
|
46
46
|
false (the default).
|
47
47
|
|
48
|
-
* Can be used with copy-on-write-friendly
|
48
|
+
* Can be used with copy-on-write-friendly GC in Ruby 2.0+
|
49
49
|
to save memory (by setting "preload_app" to true).
|
50
50
|
|
51
51
|
* Able to listen on multiple interfaces including UNIX sockets,
|
@@ -54,21 +54,19 @@ both the the request and response in between \Unicorn and slow clients.
|
|
54
54
|
|
55
55
|
* Simple and easy Ruby DSL for configuration.
|
56
56
|
|
57
|
-
* Decodes chunked
|
58
|
-
notification to be implemented as well as being able to tunnel
|
59
|
-
arbitrary stream-based protocols over HTTP.
|
57
|
+
* Decodes chunked requests on-the-fly.
|
60
58
|
|
61
59
|
== License
|
62
60
|
|
63
|
-
|
61
|
+
unicorn is copyright 2009-2018 by all contributors (see logs in git).
|
64
62
|
It is based on Mongrel 1.1.5.
|
65
63
|
Mongrel is copyright 2007 Zed A. Shaw and contributors.
|
66
64
|
|
67
|
-
|
65
|
+
unicorn is licensed under (your choice) of the GPLv2 or later
|
68
66
|
(GPLv3+ preferred), or Ruby (1.8)-specific terms.
|
69
67
|
See the included LICENSE file for details.
|
70
68
|
|
71
|
-
|
69
|
+
unicorn is 100% Free Software (including all development tools used).
|
72
70
|
|
73
71
|
== Install
|
74
72
|
|
@@ -82,14 +80,13 @@ You may install it via RubyGems on RubyGems.org:
|
|
82
80
|
You can get the latest source via git from the following locations
|
83
81
|
(these versions may not be stable):
|
84
82
|
|
85
|
-
|
86
|
-
|
83
|
+
https://yhbt.net/unicorn.git
|
84
|
+
https://repo.or.cz/unicorn.git (mirror)
|
87
85
|
|
88
|
-
You may browse the code from the web
|
89
|
-
tarballs here:
|
86
|
+
You may browse the code from the web:
|
90
87
|
|
91
|
-
*
|
92
|
-
*
|
88
|
+
* https://yhbt.net/unicorn.git
|
89
|
+
* https://repo.or.cz/w/unicorn.git (gitweb)
|
93
90
|
|
94
91
|
See the HACKING guide on how to contribute and build prerelease gems
|
95
92
|
from git.
|
@@ -102,23 +99,17 @@ In APP_ROOT, run:
|
|
102
99
|
|
103
100
|
unicorn
|
104
101
|
|
105
|
-
|
106
|
-
|
107
|
-
In RAILS_ROOT, run:
|
108
|
-
|
109
|
-
unicorn_rails
|
110
|
-
|
111
|
-
\Unicorn will bind to all interfaces on TCP port 8080 by default.
|
102
|
+
unicorn will bind to all interfaces on TCP port 8080 by default.
|
112
103
|
You may use the +--listen/-l+ switch to bind to a different
|
113
104
|
address:port or a UNIX socket.
|
114
105
|
|
115
106
|
=== Configuration File(s)
|
116
107
|
|
117
|
-
|
108
|
+
unicorn will look for the config.ru file used by rackup in APP_ROOT.
|
118
109
|
|
119
|
-
For deployments, it can use a config file for
|
110
|
+
For deployments, it can use a config file for unicorn-specific options
|
120
111
|
specified by the +--config-file/-c+ command-line switch. See
|
121
|
-
Unicorn::Configurator for the syntax of the
|
112
|
+
Unicorn::Configurator for the syntax of the unicorn-specific options.
|
122
113
|
The default settings are designed for maximum out-of-the-box
|
123
114
|
compatibility with existing applications.
|
124
115
|
|
@@ -130,16 +121,32 @@ supported. Run `unicorn -h` to see command-line options.
|
|
130
121
|
There is NO WARRANTY whatsoever if anything goes wrong, but
|
131
122
|
{let us know}[link:ISSUES.html] and we'll try our best to fix it.
|
132
123
|
|
133
|
-
|
124
|
+
unicorn is designed to only serve fast clients either on the local host
|
134
125
|
or a fast LAN. See the PHILOSOPHY and DESIGN documents for more details
|
135
126
|
regarding this.
|
136
127
|
|
128
|
+
Due to its ability to tolerate crashes and isolate clients, unicorn
|
129
|
+
is unfortunately known to prolong the existence of bugs in applications
|
130
|
+
and libraries which run on top of it.
|
131
|
+
|
137
132
|
== Contact
|
138
133
|
|
139
134
|
All feedback (bug reports, user/development dicussion, patches, pull
|
140
135
|
requests) go to the mailing list/newsgroup. See the ISSUES document for
|
141
|
-
information on the {mailing list}[mailto:unicorn-public@
|
136
|
+
information on the {mailing list}[mailto:unicorn-public@yhbt.net].
|
137
|
+
|
138
|
+
The mailing list is archived at https://yhbt.net/unicorn-public/
|
139
|
+
|
140
|
+
Read-only NNTP access is available at:
|
141
|
+
nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn and
|
142
|
+
nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
|
143
|
+
|
144
|
+
Read-only IMAP access is also avaialble at:
|
145
|
+
imaps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn.0 and
|
146
|
+
imap://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn.0
|
147
|
+
AUTH=ANONYMOUS mechanism is supported, as is any username+password
|
148
|
+
combination.
|
142
149
|
|
143
|
-
For the latest on
|
144
|
-
unicorn@
|
150
|
+
For the latest on unicorn releases, you may also finger us at
|
151
|
+
unicorn@yhbt.net or check our NEWS page (and subscribe to our Atom
|
145
152
|
feed).
|
data/SIGNALS
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
In general, signals need only be sent to the master process. However,
|
4
4
|
the signals Unicorn uses internally to communicate with the worker
|
5
5
|
processes are documented here as well. With the exception of TTIN/TTOU,
|
6
|
-
signal handling matches the behavior of {nginx}[http://nginx.
|
6
|
+
signal handling matches the behavior of {nginx}[http://nginx.org/] so it
|
7
7
|
should be possible to easily share process management scripts between
|
8
8
|
Unicorn and nginx.
|
9
9
|
|
10
10
|
One example init script is distributed with unicorn:
|
11
|
-
|
11
|
+
https://yhbt.net/unicorn/examples/init.sh
|
12
12
|
|
13
13
|
=== Master Process
|
14
14
|
|
data/Sandbox
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
= Tips for using
|
1
|
+
= Tips for using unicorn with Sandbox installation tools
|
2
2
|
|
3
3
|
Since unicorn includes executables and is usually used to start a Ruby
|
4
4
|
process, there are certain caveats to using it with tools that sandbox
|
5
5
|
RubyGems installations such as
|
6
|
-
{Bundler}[
|
7
|
-
{Isolate}[
|
6
|
+
{Bundler}[https://bundler.io/] or
|
7
|
+
{Isolate}[https://github.com/jbarnette/isolate].
|
8
8
|
|
9
9
|
== General deployment
|
10
10
|
|
@@ -34,7 +34,7 @@ is the primary issue with sandboxing tools such as Bundler and Isolate.
|
|
34
34
|
If you're bundling unicorn, use "bundle exec unicorn" (or "bundle exec
|
35
35
|
unicorn_rails") to start unicorn with the correct environment variables
|
36
36
|
|
37
|
-
ref:
|
37
|
+
ref: https://yhbt.net/unicorn-public/9ECF07C4-5216-47BE-961D-AFC0F0C82060@internetfamo.us/
|
38
38
|
|
39
39
|
Otherwise (if you choose to not sandbox your unicorn installation), we
|
40
40
|
expect the tips for Isolate (below) apply, too.
|
@@ -43,7 +43,8 @@ expect the tips for Isolate (below) apply, too.
|
|
43
43
|
|
44
44
|
This is no longer be an issue as of bundler 0.9.17
|
45
45
|
|
46
|
-
ref:
|
46
|
+
ref:
|
47
|
+
https://yhbt.net/unicorn-public/8FC34B23-5994-41CC-B5AF-7198EF06909E@tramchase.com/
|
47
48
|
|
48
49
|
=== BUNDLE_GEMFILE for Capistrano users
|
49
50
|
|
@@ -58,14 +59,14 @@ the before_exec hook:
|
|
58
59
|
|
59
60
|
If you're using an older Bundler version (0.9.x), you may need to set or
|
60
61
|
reset GEM_HOME, GEM_PATH and PATH environment variables in the
|
61
|
-
before_exec hook as illustrated by
|
62
|
+
before_exec hook as illustrated by https://gist.github.com/534668
|
62
63
|
|
63
64
|
=== Ruby 2.0.0 close-on-exec and SIGUSR2 incompatibility
|
64
65
|
|
65
66
|
Ruby 2.0.0 enforces FD_CLOEXEC on file descriptors by default. unicorn
|
66
|
-
has been prepared for this behavior since unicorn 4.1.0,
|
67
|
-
|
68
|
-
https://
|
67
|
+
has been prepared for this behavior since unicorn 4.1.0, and bundler
|
68
|
+
needs the "--keep-file-descriptors" option for "bundle exec":
|
69
|
+
https://bundler.io/man/bundle-exec.1.html
|
69
70
|
|
70
71
|
== Isolate
|
71
72
|
|
data/TODO
CHANGED
data/TUNING
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
= Tuning
|
1
|
+
= Tuning unicorn
|
2
2
|
|
3
|
-
|
3
|
+
unicorn performance is generally as good as a (mostly) Ruby web server
|
4
4
|
can provide. Most often the performance bottleneck is in the web
|
5
5
|
application running on Unicorn rather than Unicorn itself.
|
6
6
|
|
7
|
-
==
|
7
|
+
== unicorn Configuration
|
8
8
|
|
9
9
|
See Unicorn::Configurator for details on the config file format.
|
10
10
|
+worker_processes+ is the most-commonly needed tuning parameter.
|
@@ -14,12 +14,15 @@ See Unicorn::Configurator for details on the config file format.
|
|
14
14
|
* worker_processes should be scaled to the number of processes your
|
15
15
|
backend system(s) can support. DO NOT scale it to the number of
|
16
16
|
external network clients your application expects to be serving.
|
17
|
-
|
17
|
+
unicorn is NOT for serving slow clients, that is the job of nginx.
|
18
18
|
|
19
19
|
* worker_processes should be *at* *least* the number of CPU cores on
|
20
|
-
a dedicated server
|
21
|
-
responses that are /not/
|
22
|
-
workaround those inefficiencies.
|
20
|
+
a dedicated server (unless you do not have enough memory).
|
21
|
+
If your application has occasionally slow responses that are /not/
|
22
|
+
CPU-intensive, you may increase this to workaround those inefficiencies.
|
23
|
+
|
24
|
+
* Under Ruby 2.2 or later, Etc.nprocessors may be used to determine
|
25
|
+
the number of CPU cores present.
|
23
26
|
|
24
27
|
* worker_processes may be increased for Unicorn::OobGC users to provide
|
25
28
|
more consistent response times.
|
@@ -55,7 +58,7 @@ See Unicorn::Configurator for details on the config file format.
|
|
55
58
|
* UNIX domain sockets are slightly faster than TCP sockets, but only
|
56
59
|
work if nginx is on the same machine.
|
57
60
|
|
58
|
-
== Other
|
61
|
+
== Other unicorn settings
|
59
62
|
|
60
63
|
* Setting "preload_app true" can allow copy-on-write-friendly GC to
|
61
64
|
be used to save memory. It will probably not work out of the box with
|
@@ -69,10 +72,28 @@ See Unicorn::Configurator for details on the config file format.
|
|
69
72
|
have them unbuffered (File#sync = true) or they are
|
70
73
|
record(line)-buffered in userspace before any writes.
|
71
74
|
|
72
|
-
== Kernel Parameters (Linux sysctl)
|
75
|
+
== Kernel Parameters (Linux sysctl and sysfs)
|
73
76
|
|
74
77
|
WARNING: Do not change system parameters unless you know what you're doing!
|
75
78
|
|
79
|
+
* Transparent hugepages (THP) improves performance in many cases,
|
80
|
+
but can also increase memory use when relying on a
|
81
|
+
copy-on-write(CoW)-friendly GC (Ruby 2.0+) with "preload_app true".
|
82
|
+
CoW operates at the page level, so writing to a huge page would
|
83
|
+
trigger a 2 MB copy (x86-64), as opposed to a 4 KB copy on a
|
84
|
+
regular (non-huge) page.
|
85
|
+
|
86
|
+
Consider only allowing THP to be used when it is requested via the
|
87
|
+
madvise(2) syscall:
|
88
|
+
|
89
|
+
echo madvise >/sys/kernel/mm/transparent_hugepage/enabled
|
90
|
+
|
91
|
+
Or disabling it system-wide, via "never".
|
92
|
+
|
93
|
+
n.b. "page" in this context only applies to the OS kernel,
|
94
|
+
Ruby GC implementations also use this term for the same concept
|
95
|
+
in a way that is agnostic to the OS.
|
96
|
+
|
76
97
|
* net.core.rmem_max and net.core.wmem_max can increase the allowed
|
77
98
|
size of :rcvbuf and :sndbuf respectively. This is mostly only useful
|
78
99
|
for UNIX domain sockets which do not have auto-tuning buffer sizes.
|