Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Unicorn need to be deployed together with Nginx?

I would like to know the difference between Nginx and Unicorn. As far as I understand, Nginx is a web server while Unicorn is a Ruby HTTP server.

Since both Nginx and Unicorn can handle HTTP requests, what is the need to use the combination of Nginx and Unicorn for RoR applications?

like image 283
loganathan Avatar asked Jan 05 '12 09:01

loganathan


People also ask

What is the purpose of with NGINX server?

It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.

What is Unicorn Ruby?

Unicorn is an HTTP server for Ruby, similar to Mongrel or Thin. It uses Mongrel's Ragel HTTP parser but has a dramatically different architecture and philosophy. In the classic setup you have nginx sending requests to a pool of mongrels using a smart balancer or a simple round robin.

What is NGINX stack?

Nginx, pronounced "engine-X", is the second most common web server among the top 100,000 websites. Nginx also functions well as a reverse proxy to handle requests and pass back responses for Python WSGI servers or even other web servers such as Apache.

What is NGINX and how it works medium?

NGINX is a web server that also acts as an email proxy, reverse proxy, and load balancer. NGINX's structure is asynchronous and also event-driven; which ensures the processing of multiple requests at the same time. NGINX is easily highly scalable, which ensures that its service grows along with its clients' traffic.


1 Answers

Nginx is a pure web server that's intended for serving up static content and/or redirecting the request to another socket to handle the request.

Unicorn is a Rack web server and only intended to host a 'Rack App' which is usually generating dynamic content. Rack apps can also serve up static content but it's less efficient than most other traditional web servers.

Most RoR setups use a combination of both traditional web servers and Rack servers to apply the best of both of their capabilities. Nginx is incredibly fast at request redirection through proxy balancing and serving up static content. Unicorn is quite capable of processing HTTP headers and balancing inbound requests to Ruby for processing.

like image 143
Nick Avatar answered Oct 02 '22 21:10

Nick