Nginx with big geo maps affects whole system performance on reload
mdounin at mdounin.ru
Tue Aug 3 14:41:27 UTC 2021
On Tue, Aug 03, 2021 at 09:13:07AM -0400, SannisDev wrote:
> I'm running Nginx 1.20.1 on CentOS 8.4.2105 with a quite large geo maps,
> including country/isp/connection for both IPv4 and IPv6, with raw size about
> Hardware is: 2x Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz, 64Gb RAM
> On nginx testconf or reload I'm experiencing increase of running nginx
> latency, 99th percentile growth from 10ms to seconds.
> I suppose that this cache misses is the root cause of system slowdown on
> Maybe someone have same problem and have some suggestions how to improve
> this situation?
Loading large geo map can be quite expensive, that's expected:
nginx has to parse all the records provided in text and build
corresponding radix tree. Make sure you have enough spare CPU and
free memory to actually do the work without affecting other tasks
on the server. In particular, in my practice it is a good idea to
make sure the number of nginx worker processes is less than number
of available cores, or you'll risk getting high latencies when
doing CPU-intensive tasks like parsing geo maps or compressing
Also it might be a good idea to switch to using ranges and a
separate include file, so nginx will be able to cache parsing
results in a binary file.
More information about the nginx