Why do we need nginx with thin on production setup?
Asked Answered
S

3

15

Why do we need to install nginx with thin on production setup, As thin is itself a web server. Every blog post people are using ruby+rails+nginx+thin?

Steddman answered 5/7, 2013 at 6:28 Comment(0)
H
11

As stated by Michael nginx balances thin (whatever that means). But another reason to use nginx in front of any ruby server is to serve static files (if you use page caching, they also can be served by nginx), which means requests wont even touch your ruby app, and increase a lot your performance. Also nginx although it seems to be the popular choice on the ruby/rails community, there are other alternatives like apache.

Heshvan answered 5/7, 2013 at 12:8 Comment(0)
E
3

Ngnix is used to load balance thin. You may wish to use Unicorn instead. More on the matter here: http://cmelbye.github.io/2009/10/04/thin-vs-unicorn.html

Ellary answered 5/7, 2013 at 7:6 Comment(2)
Not always possible. Thin allows for long running connections, streaming etc. Unicorn doesn't allow either so it highly depends on what your app/backend require.Hawkbill
True, but Nginx takes care of long running connections, etc instead.Ellary
L
3

Thin and all Ruby servers are slower than servers written in C language - e.g. Nginx and Apache, when serving static files - images, rendered html etc.
Nginx is lightweight and has great concurrency support. So when you have a long data transmission like upload, download or slow client it pays off. Instead of a heavy Ruby process hanging in memory, waiting for the end of transmission, you have a light Nginx process that will pass upload to a Ruby process only after the file is uploaded. Or receive response from Rails, stop Rails process and serve response for as long as required to the client.

Lifeboat answered 15/12, 2013 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.