Fwd: Lua shared storage inconsistent?
d4fseeker at gmail.com
Thu Mar 14 00:39:57 UTC 2013
I'm trying to count with a Lua-script the concurrent requests to a given
virtual host on the backend to which Nginx relays als reverse proxy.
My current code is somewhat more complex, but I try to reduce it to the
problematic one. Assuming we have a shared storage with sufficient memory
storage (let's say 100MB) I try the following:
ngx.shared.counter:add(ngx.var.host,0) --makes sure the value exists
I assumed -since the storage is supposedly atomic and shared- that this
will work. However when running a benchmark with eg 500 concurrent
connections, I will always be somewhat around 70 units in the minus at the
end of the benchmark. How come?
I tried setting the incrementer in other phases such as rewrite and the
decrementer in the body-phase, but that didn't change anything.
Also I noticed that taking a copy of the shared storage will not have that
copy update during sleep-loops of the given request and I have to fetch a
new one (with the penalty of keeping allocating new RAM)
Is there anything fundamentally wrong with my understanding of Nginx, is
there a bug in the lua implementation or what happened?
Thank you for helping me out - I certainly couldn't so far...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx