vozlt / nginx-module-vts

Nginx virtual host traffic status module
BSD 2-Clause "Simplified" License
3.24k stars 464 forks source link

periodic cleanup of shared memory? #282

Open skycyan opened 1 year ago

skycyan commented 1 year ago

In the nginx-module-vts, when using vhost_traffic_status_filter_by_set_key, it leads to continuous growth of shared memory. Is it possible to periodically clean up the data in shared memory, for example, retaining only the data from the last 7 days?

SuperQ commented 1 year ago

No, not really possible without restarting. The reason is you can't do partial cleanup of data easily. Most of the monitoring uses counters, which need to be monotonic. It also needs to be consistent across counters in the same metric family.

From a "principal of lease surprise" perspective, a reload or restart that clears all metrics is what is possible.

vozlt commented 1 year ago

The shared memory used by the vts module is not dynamically increased after initial allocation. If you want to delete data in the shared memory allocated during operation, you can use status control api. Even if you use this command, the allocated shared memory remains the same. How much shared memory's maxSize, usedSize, usedNode is on the status page on average?

FYI. https://blog.openresty.com/en/how-nginx-shm-consume-ram/#fake-memory-leaks