Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Fwd: Lua shared storage inconsistent?

$
0
0
Hello,

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:

** phase_access:
ngx.shared.counter:add(ngx.var.host,0) --makes sure the value exists
ngx.shared.counter:incr(ngx.var.host,1)


** phase_log
ngx.shared.counter:incr(ngx.var.host,-1)



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...
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>