Odd OpenResty Timing Issue

30 views
Skip to first unread message

Mark Walters

unread,
Sep 28, 2017, 8:51:48 PM9/28/17
to openresty-en
We're experiencing an odd timing issue with OpenResty, and hoping you could shed some light.

We have two nginx configs, both identical except for an access_by_lua_block.

When we run load tests against the two configs, the one without the access_by_lua_block is on average ~30ms faster than the one with.

I have added (possibly a naive) timer to the actual Lua code and on average that block takes ~5ms.

I use `os.clock()` to get the time at the beginning and end of the Lua block and write that time to an nginx variable to be displayed in the access logs.
local start_time = os.clock()

-- Lua code here

local end_time = os.clock()
local duration_time = string.format("%.3f", end_time - start_time)
if ngx.var.lua_time ~= nil then
    ngx.var.lua_time = duration_time
end

Can you think of any reason for the ~25ms discrepancy?
Reply all
Reply to author
Forward
0 new messages