How to retrieve information about cache expiration?

Giovani Rinaldi giovani.rinaldi at azion.com
Fri May 20 12:42:03 UTC 2016


Hello,

I'm trying to retrieve information regarding the number of times a cache
file is expired (either forced, due to cache pressure, or not, such as time
expiration). I've noticed that the cache manager process logs this info
when configured with debug level for the error.log directive. An example is
the following line:

[debug] 5461#5461: http file cache expire:
"/data/nginx/cache/c/1b/cc1651d5d24be40ce402c4e583cd01bc"

I see, currently, two possible ways of achieving such goal. One is parsing
the log file (using a cyclic memory buffer configured to a tmpfs/ramfs, as
described in http://nginx.org/en/docs/debugging_log.html#memory) with an
external executable, in order to not increase IO ops or delay the cache
processing under high load.

Another option would be to develop a module that would be called by the
cache manager process every time its event loop executes, so it could
access to the memory log, parse it and count the amount of times an
expiration occurred. Although it is my understanding that current module
hooks only allow access to memory (including the log struct) allocated by
the worker process, I wonder if there is any other way to hook external
code into the cache manager process (maybe by overloading some global
static struct that contains any function declaration pertaining to the log
or cache managing module?).

Is there any better way of achieving this goal? If not, are any of these
two approaches doable/recommended? Any advice would be most welcome.

The NGINX version I'm currently using is the 1.8.1, and altering its code
(such as patching any original source code) is something I would like to
avoid at all costs.

Thanks in advance.
Giovani.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160520/21287f9f/attachment.html>


More information about the nginx-devel mailing list