Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js_periodic / Reading status connections growing #692

Closed
jaysee opened this issue Jan 29, 2024 · 3 comments
Closed

js_periodic / Reading status connections growing #692

jaysee opened this issue Jan 29, 2024 · 3 comments

Comments

@jaysee
Copy link

jaysee commented Jan 29, 2024

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 servercontext seem more appropriate no? (I my use case, it is!)

@xeioex
Copy link
Contributor

xeioex commented Jan 29, 2024

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.

@jaysee
Copy link
Author

jaysee commented Jan 30, 2024

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

@xeioex
Copy link
Contributor

xeioex commented Jan 31, 2024

@jaysee

it seems that a new connection is created and maintained

It is an internal accounting problem, all the internal requests are actually closed, but the internal counter for the number of reading requests is not updated accordingly. Thank you for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants