Is it bad to use unicorn without nginx? What for?

I read that unicorn is fast serving static content, slow users, redirects.

Why is nginx + unicorn vs unicorn unity better and scale up the number of unicorn workers when needed?

Do you have any numbers showing how fast nginx is at each of these things (redirecting, proxying, serving static content)?

+3


source to share


1 answer


According to Heroku DevCenter , Unicorn workers are vulnerable to slow clients .

Each worker can only handle one request, and if the client is not ready to accept the entire response (aka "slow client"), the Unicorn worker is blocked from sending a response and cannot process the next . Since every Unicorn worker again takes up a significant chunk of RAM ( see Heroku , it claims to handle 2-4 processes with 512MB of RAM), you cannot rely on the number of workers, as it is the number of clients that can render your application unusable . pretending to have slow connections.

When nginx is behind, Unicorn can flush the entire response to the nginx buffer and immediately switch to processing the next request.



However, nginx with a single Unicorn worker behind is much more reliable than a bunch of Unicorn workers exposed directly.

NB: for people using ancient rubies: if you will be using the Unicorn set of workers, consider migrating to at least Ruby 2.0 to reduce RAM consumption by sharing shared data across forked processes ( ref ).

+6


source







All Articles