ngx_http_geoip2_module icon indicating copy to clipboard operation
ngx_http_geoip2_module copied to clipboard

high cpu usage on heavy traffic

Open Vladislavik opened this issue 2 years ago • 2 comments

Hi is there any advice or other when i try to use this module on a high load server nginx starts to consume a lot of cpu is there any caches for the found ip data in the database not to look it up again on the next request from the same ip or any other recommendation to reduce cpu usage. Almost on ddos it is 100% CPU usage with nginx...

Vladislavik avatar Jun 11 '22 18:06 Vladislavik

I would start with generating a flamegraph of the server when it's not under attack and when it is under attack. That will help with identifying where the CPU increase is and if it is in fact due to geo IP look up.

Right now, there is no caching of geoip information between requests.

leev avatar Jun 13 '22 17:06 leev

Hello @leev,

first thank you for this nice nginx module. We also use it on every our servers for country blocking and in case of ddos attacks. I really have no idea how to program a nginx module but there is a efficient way to improve the performance of this module?

How this module works in detail?

  1. The geoip database is loaded into RAM on nginx start/reload
  2. Every nginx request is checked from database on local disk

If 2, maybe it could improve the performance to copy the geoip database into tmpfs directory because of faster RAM?

Because we also can see high cpu load on high traffic servers with active geoip2 module. We also would pay for a nice performance update.

tobias992 avatar Feb 02 '23 16:02 tobias992