js_periodic / Reading status connections growing
Closed this issue · 3 comments
I recently had some troubles with Too many open files
errors in my logs and I found that each call of thejs_periodic
makes reading status connections
growing
By Reading status connections
I mean those reported by stub_status
(=>Reading: 187 Writing: 7 Waiting: 109)
reading is growing by the number of "js_periodic" calls each each 10s (wich is the setted timeout)
nginx.conf
[...]
js_import test from njs/test.js;
[...]
server {
[...]
location / {
js_periodic test.test interval=10s;
}
}
test.js
async function test(s) {
return;
}
var index = {
test
};
export default index;
This is another discution, but why js_periodic
is callable in Location context
. As it is periodic, I can't see a relation with Location? Beeing able to call it at server
context seem more appropriate no? (I my use case, it is!)
Hi @jaysee,
js_periodic
creates an internal connection to reuse the existing code, this is expected.
The reason for js_periodic
to be called in a location context is mostly related to directives inheritance and a desire to not to clog a server level with js_periodic specific directives, see the example.
Hi @xeioex,
Thanks for the clarification about location context, I was over charging the things with my setup, I made a simpler setup based on the example, only 1 call now.
But still at every timeout of the js_periodic
I got 1 more reading connection on the stub_status
, at each call, it seems that a new connection is created and maintained:
curl -s localhost/nginx_status
Active connections: 2
server accepts handled requests
734 734 4813
Reading: 49 Writing: 1 Waiting: 1