Search code examples
ruby-on-railsnginxunicorn

How rails app works with Unicorn and NginX?


i would like to know how a browser request flow b/w Nginx and Unicorn to work with rails app? Explain. Thanks in advance.


Solution

  • Very generic question, thus a generic answer:

    Nginx is usually set up as a reverse-proxy and static asset server.

    Browser -(http)-> Nginx -(http)-> Unicorn worker -(rack)-> rails app
    

    All unicorn workers share the same listening socket, balancing is done by OS via simple rule of 'first come - first serve'