DEPLOY FAQ HACKING LICENSE NEWS README SIGNALS Sandbox Static_Files Summary TUNING Test_Suite rainbows_1 vs_Unicorn
Rainbows ActorSpawn AppPool Base Configurator Coolio CoolioThreadPool CoolioThreadSpawn DevFdResponse Epoll EventMachine FiberPool FiberSpawn MaxBody NeverBlock Rev RevFiberSpawn RevThreadPool RevThreadSpawn Revactor Sendfile ServerToken StreamResponseEpoll ThreadPool ThreadSpawn ThreadTimeout WriterThreadPool WriterThreadSpawn XEpoll XEpollThreadPool XEpollThreadSpawn

Methods

#Rainbows! #client_header_buffer_size #client_max_body_size #client_max_header_size #copy_stream #keepalive_requests #keepalive_timeout #use #worker_connections

module Rainbows::Configurator

This module adds Rainbows! to the Unicorn::Configurator Rainbows!-specific configuration options must be inside a the Rainbows! block, otherwise Unicorn::Configurator directives may be used anywhere in the file.

Warning: The "timeout" directive in unicorn is far more dangerous in Rainbows!, since ALL requests running on a process will be lost on worker death, not just one. Instead, handle application-level timeouts yourself: bogomips.org/unicorn/Application_Timeouts.html

Rainbows! do
  use :ThreadSpawn # concurrency model to use
  worker_connections 400
  keepalive_timeout 0 # zero disables keepalives entirely
  client_max_body_size 5*1024*1024 # 5 megabytes
  keepalive_requests 666 # default:100
  client_header_buffer_size 2 * 1024 # 2 kilobytes
end

# the rest of the Unicorn configuration...
worker_processes 8
stderr_path "/path/to/error.log"
stdout_path "/path/to/output.log"

Public Instance Methods

Rainbows! (&block) source

Configures Rainbows! with a given concurrency model to use and a worker_connections upper-bound. This method should be called inside a Unicorn/Rainbows! configuration file.

All other methods in Rainbows::Configurator must be called inside this block.

client_header_buffer_size (bytes) source

This governs the amount of memory allocated for an individual read(2) or recv(2) system call when reading headers. Applications that make minimal use of cookies should not increase this from the default.

Rails applications using session cookies may want to increase this to 2048 bytes or more depending on expected request sizes.

Increasing this will increase overall memory usage to your application, as you will need at least this amount of memory for every connected client.

Default: 1024 bytes

client_max_body_size (bytes) source

Limits the maximum size of a request body for all requests. Setting this to nil disables the maximum size check.

Default: 1 megabyte (1048576 bytes)

If you want endpoint-specific upload limits and use a "rack.input"-streaming concurrency model, see the Rainbows::MaxBody

client_max_header_size (bytes) source

Limits the maximum size of a request header for all requests.

Default: 112 kilobytes (114688 bytes)

Lowering this will lower worst-case memory usage and mitigate some denial-of-service attacks. This should be larger than client_header_buffer_size.

copy_stream (klass) source

Allows overriding the klass where the copy_stream method is used to do efficient copying of regular files, pipes, and sockets.

This is only used with multi-threaded concurrency models:

Due to existing bugs in the Ruby IO.copy_stream implementation, Rainbows! uses the "sendfile" RubyGem that instead of #copy_stream to transfer regular files to clients. The "sendfile" RubyGem also supports more operating systems, and works with more concurrency models.

Recent Linux 2.6 users may override this with "IO::Splice" from the "io_splice" RubyGem:

require "io/splice"
Rainbows! do
  copy_stream IO::Splice
end

Keep in mind that splice(2) itself is a relatively new system call and has been buggy in many older Linux kernels. If you're proxying the output of sockets to the client, be sure to use "io_splice" 4.1.1 or later to avoid stalling responses.

Default: IO on Ruby 1.9+, false otherwise

keepalive_requests (count) source

This limits the number of requests which can be made over a keep-alive connection. This is used to prevent single client from monopolizing the server and to improve fairness when load-balancing across multiple machines by forcing a client to reconnect. This may be helpful in mitigating some denial-of-service attacks.

Default: 100 requests

keepalive_timeout (seconds) source

Sets the value (in seconds) the server will wait for a client in between requests. The default value should be enough under most conditions for browsers to render the page and start retrieving extra elements.

Setting this value to 0 disables keepalive entirely

Default: 5 seconds

use (model, *options) source

Select a concurrency model for use with Rainbows!. You must select this with a Symbol (prefixed with ":"). Thus if you wish to select the Rainbows::ThreadSpawn concurrency model, you would use:

Rainbows! do
  use :ThreadSpawn
end

See the Summary document for a summary of supported concurrency models. options may be specified for some concurrency models, but the majority do not support them.

Default: :Base (no concurrency)

worker_connections (clients) source

This limits the number of connected clients per-process. The total number of clients on a server is worker_processes * worker_connections.

This option has no effect with the Base concurrency model, which is limited to 1.

Default: 50


Pages Classes Methods
mail archives: https://bogomips.org/rainbows-public/
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.rainbows 
	nntp://news.gmane.org/gmane.comp.lang.ruby.rainbows.general 
public: rainbows-public@bogomips.org / private: rainbows@bogomips.org