about summary refs log tree commit homepage
path: root/TUNING
diff options
context:
space:
mode:
Diffstat (limited to 'TUNING')
-rw-r--r--TUNING40
1 files changed, 31 insertions, 9 deletions
diff --git a/TUNING b/TUNING
index 9a54a01..ca291ad 100644
--- a/TUNING
+++ b/TUNING
@@ -1,12 +1,34 @@
-= Tuning Unicorn
+= Tuning \Unicorn
 
-Unicorn performance is generally as good as a (mostly) Ruby web server
+\Unicorn performance is generally as good as a (mostly) Ruby web server
 can provide.  Most often the performance bottleneck is in the web
 application running on Unicorn rather than Unicorn itself.
 
-== Unicorn Configuration
+== \Unicorn Configuration
 
 See Unicorn::Configurator for details on the config file format.
++worker_processes+ is the most-commonly needed tuning parameter.
+
+=== Unicorn::Configurator#worker_processes
+
+* worker_processes should be scaled to the number of processes your
+  backend system(s) can support.  DO NOT scale it to the number of
+  external network clients your application expects to be serving.
+  \Unicorn is NOT for serving slow clients, that is the job of nginx.
+
+* worker_processes should be *at* *least* the number of CPU cores on
+  a dedicated server.  If your application has occasionally slow
+  responses that are /not/ CPU-intensive, you may increase this to
+  workaround those inefficiencies.
+
+* worker_processes may be increased for Unicorn::OobGC users to provide
+  more consistent response times.
+
+* Never, ever, increase worker_processes to the point where the system
+  runs out of physical memory and hits swap.  Production servers should
+  never see heavy swap activity.
+
+=== Unicorn::Configurator#listen Options
 
 * Setting a very low value for the :backlog parameter in "listen"
   directives can allow failover to happen more quickly if your
@@ -30,6 +52,11 @@ See Unicorn::Configurator for details on the config file format.
   and may also thrash CPU caches, cancelling out performance gains
   one would normally expect.
 
+* UNIX domain sockets are slighly faster than TCP sockets, but only
+  work if nginx is on the same machine.
+
+== Other \Unicorn settings
+
 * Setting "preload_app true" can allow copy-on-write-friendly GC to
   be used to save memory.  It will probably not work out of the box with
   applications that open sockets or perform random I/O on files.
@@ -40,12 +67,7 @@ See Unicorn::Configurator for details on the config file format.
 * On POSIX-compliant filesystems, it is safe for multiple threads or
   processes to append to one log file as long as all the processes are
   have them unbuffered (File#sync = true) or they are
-  record(line)-buffered in userspace.
-
-* worker_processes should be scaled to the number of processes your
-  backend system(s) can support.  DO NOT scale it to the number of
-  external network clients your application expects to be serving.
-  Unicorn is NOT for serving slow clients, that is the job of nginx.
+  record(line)-buffered in userspace before any writes.
 
 == Kernel Parameters (Linux sysctl)