Web Servers

Back to Production-Engineering

Serve static files, but with the right modules, can also serve dynamic web apps. Apache is more popular with more features, NGINX is faster with less features. Neither can serve Ruby web apps out-of-the-box and need additional modules.

Apache and NGINX can also act as reverse proxies meaning they can take incoming HTTP requests and forward it to another server, which also speaks HTTP.

Web servers are the front-most layer of traffic handling. Setup:

Apache vs Nginx

Both solutions are capable of handling diverse workloads. They are different in what they excel at. One big difference is how they handle connections and traffic.


The Apache HTTP server was created in 1995.


2004, known for light-weight resource utilization and ability to scale easily on minimal hardware


Mongrel and other production app servers and WEBrick

Mongrel is a Ruby "application server":

  1. It loads the Ruby app in its own process space
  2. Sets up a TCP socket allowing it to communicate with the internet (Mongrel listens for HTTP requests on this socket and passes the request data to the Ruby web app)

  3. Ruby web app returns an object which describes what the HTTP response should look like, Mongrel converts it to an actual HTTP response and sends it back over the socket.

Mongrel is dated, and newer comparable application servers are:

WEBrick is the built in Ruby app server, but WEBrick is not fit for production (written entirely in ruby so poor performance).

App Servers

Some app servers directly have access to the internet via port 80 while most others need to be put behind a reverse proxy web server using Apache or NGINX.

More reading at I/O Concurrency Models

Capistrano is used for automating the "deployment" process.