Expert needed to Tune Nginx For Best Performance

j94305 nginx-forum at forum.nginx.org
Sat Nov 16 09:26:01 UTC 2019


Optimizing for production is not simply an optimization of one component,
e.g., NGINX.

This is also about your security model, the application architecture and
scaling abilities.

If you simply have static files to be served, place them into a memory-based
file system and you'll serve them blindingly fast - in theory. Actual
performance will depend on the locations of your clients, with their
latencies and bandwidths, so the approach may be not to accelerate one NGINX
server location, but rather have a geographic distribution to serving
content at the edge.

If you need to serve to lower-bandwidth clients, gzip compression may be
essential for latencies. If you have clients with broadband capabilities,
you may want to save the extra CPU cycles for other tasks.

If your security model requires complex signature verification on every
request, you may need significantly more CPU power in there, compared to
when you simply handle easily-verifiable cookies (which were assigned
through a more compute-intensive calculation and verification scheme - but
only once per session). OIDC-based schemes come to my mind.

If you have different types of loads, it is sensible to separate them.
Static files will be served by one cluster of servers, dynamic content will
be served by another. Having auto-scaling groups on the application side ,
you can scale well, assuming state-less micro-services there.

If there is a broadly varying spectrum of load situations, you may want to
consider clusters of NGINX, possibly with auto-scaling, to handle loads more
effectively. Optimizing single NGINX instances may not what will really
boost performance enough.

So, my point is: optimizing any application environment for production use
is not just a matter of nifty directives to speed up NGINX. It's a question
of optimizing the architecture AND its components, including the application
services. I've seen massive speed-ups just by changing the application into
a set of state-less micro-services - focus on "state-less".

While you will find people who help you with NGINX optimization in a given
scenario, this may not be what you really need to optimize your entire
application, including NGINX.

Cheers,
--j.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286223,286224#msg-286224



More information about the nginx mailing list