in Coding, Lua, nginx

NGINX Timer Resolution

Using ngx.time or ngx.now is encouraged over using Lua’s built in functions because they use the cached time rather than performing a syscall, but how often is the cache updated?

After a bit of a dig, it turns out there’s no absolute answer, because the cache is actually updated when a kernel event fires:

It can be set manually using nginx’s timer_resolution
http://nginx.org/en/docs/ngx_core_module.html#timer_resolution
but this is not recommended because it either causes too many syscalls if set too low, or necessary time lag if set too high.

https://groups.google.com/d/msg/openresty-en/OdNzfh8rlzk/EQHF-hlhlQ0J