Web
    Web Overview
    URL
    HTML
    CSS
    Markdown
    Progressive Web App
    Web Frameworks
    Web Hosting

Web Server

Updated: 2022-02-06

Features of Web Server

  • Static file serving.
  • SSL/TLS support.
  • Virtual hosts.
  • Reverse proxying.
  • Load balancing.
  • Compression.
  • Access controls.
  • URL rewriting.
  • Custom logging.
  • Server-side includes.
  • Limited WebDAV.
  • FLV streaming.
  • FastCGI.

Event-based vs Process-based

The main advantage of the asynchronous approach is scalability. In a process-based server, each simultaneous connection requires a thread which incurs significant overhead. An asynchronous server, on the other hand, is event-driven and handles requests in a single (or at least, very few) threads.

Nginx vs Apache Http Server

  • Nginx: event-based
  • Apache: process-based

Nginx is faster at serving static files and consumes much less memory for concurrent requests. Because Nginx is event-based, it doesn't need to spawn new processes or threads for each request, so its memory usage is very low.

499 CLIENT CLOSED REQUEST

499 is a non-standard status code used by nginx: if a client closes the connection while nginx is processing the request.

E.g. if nginx is used as reverse proxy, it will wait for the backend server(e.g. uWSGI) for X seconds, after that it will respond to the client with a 504 Gateway Timeout error. If the backend server is dead or dies while nginx is waiting, nginx sees that right away and returns 499 error

Nginx Restart

$ sudo nginx -s reload

https://en.wikipedia.org/wiki/Comparison_of_web_server_software

WSGI, Java Servlet

On one side: full web server like Apache or Nginx; on the other side: application. WSGI is the middleware that implements both API.

Java's servlet API makes it possible for applications written with any Java web application framework to run in any web server that supports the servlet API.