Redirecting to ...




Rack middleware to limit application-level concurrency independently of network conncurrency in Rainbows! Since the worker_connections option in Rainbows! is only intended to limit the number of simultaneous clients, this middleware may be used to limit the number of concurrent application dispatches independently of concurrent clients.

Instead of using M:N concurrency in Rainbows!, this middleware allows M:N:P concurrency where P is the AppPool :size while M remains the number of worker_processes and N remains the number of worker_connections.

rainbows master
 \_ rainbows worker[0]
 |  \_ client[0,0]------\      ___app[0]
 |  \_ client[0,1]-------\    /___app[1]
 |  \_ client[0,2]-------->--<       ...
 |  ...                __/    `---app[P]
 |  \_ client[0,N]----/
 \_ rainbows worker[1]
 |  \_ client[1,0]------\      ___app[0]
 |  \_ client[1,1]-------\    /___app[1]
 |  \_ client[1,2]-------->--<       ...
 |  ...                __/    `---app[P]
 |  \_ client[1,N]----/
 \_ rainbows worker[M]
    \_ client[M,0]------\      ___app[0]
    \_ client[M,1]-------\    /___app[1]
    \_ client[M,2]-------->--<       ...
    ...                __/    `---app[P]
    \_ client[M,N]----/

AppPool should be used if you want to enforce a lower value of P than N.

AppPool has no effect on the Rev or EventMachine concurrency models as those are single-threaded/single-instance as far as application concurrency goes. In other words, P is always one when using Rev or EventMachine. As of Rainbows! 0.7.0, it is safe to use with Revactor and the new FiberSpawn and FiberPool concurrency models.

Since this is Rack middleware, you may load this in your Rack file and even use it in threaded servers other than Rainbows!

use Rainbows::AppPool, :size => 30
map "/lobster" do

You may to load this earlier or later in your middleware chain depending on the concurrency/copy-friendliness of your middleware(s).

Public Class Methods

new(app, opt = {}) view method source

opt is a hash, :size is the size of the pool (default: 6) meaning you can have up to 6 concurrent instances of app within one Rainbows! worker process. We support various methods of the :copy option: dup, clone, deep and none. Depending on your app, one of these options should be set. The default :copy is :dup as is commonly seen in existing Rack middleware.

Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.

We love to hear from you!
Email patches (with git send-email), pull requests, questions, bug reports, suggestions, etc. to us publically at
No subscription to the mailing list is necessary, just let us know to Cc: you if you're unsubscribed.
To subscribe, email with "subscribe" in the Subject and respond to the automated confirmation message.
Do not waste bandwidth with HTML, HTML mail will not be read.
Quote only parts you're responding to and do not top post.
For sensitive topics, email us privately at