Nginx – Can advanced web servers be faster than basic web servers

cginginxthttpdweb-server

A bsic web server such as python SimpleHTTPServer or THTTPD reads static files with least process; thus is quite fast. Normally, adding more features to create an advanced web server (but still lightweight such as nginx) will slow down this process.

Can an advanced web server play a trick to make the process faster? or simpler than simplest is impossible, and the simplest is fastest way to read static files? I mean can nginx (or other lightweight web servers which claim to be fast) be faster than THTTPD (or other basic web servers with minimal process)?

And what about CGI scripts, as HTTPD and python CGIHTTPServer can simply execute cgi scripts.

Best Answer

Web servers with less features have a smaller memory and CPU footprint, which makes them faster at doing specific tasks. Some of them are also specifically designed to one task well.

This is why software like PHP-FPM has emerged. Instead of having a bloated apache2 process which loads a PHP module for every single process, you rather use a front-end for static files (like nginx), and a back-end (like PHP-FPM via FastCGI) for dynamic applications.

It does however depend on your usage and enviroment. If you're doing 99% dynamic processing then it might not be worth the hassle. One good example could be a Java application.. it doesnt make much sense to do all the work of setting up a front-end and a back-end, when you could just use tomcat and nothing else.

Related Topic