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

option to limit total threads #12

Open
Grinnz opened this issue Oct 18, 2019 · 9 comments
Open

option to limit total threads #12

Grinnz opened this issue Oct 18, 2019 · 9 comments

Comments

@Grinnz
Copy link
Contributor

Grinnz commented Oct 18, 2019

When not using a pool or when extra_threads is set, NDN spawns additional one-off threads for requests beyond what the pool can handle. This can lead to resource exhaustion in extreme cases. A max_threads or similar option could limit how many threads can be spawned at once before queueing.

@olegwtf
Copy link
Owner

olegwtf commented Oct 19, 2019

Can u make pull request?

@olegwtf
Copy link
Owner

olegwtf commented Oct 26, 2019

Ok. I started to work on it.

@olegwtf
Copy link
Owner

olegwtf commented Oct 31, 2019

Looks implemented in 7076f00. Can you test it?

new(threads_limit => 10); # do not count timed out threads in limit
new(threads_strict_limit => 10); # count all threads including timed out

@olegwtf
Copy link
Owner

olegwtf commented Nov 5, 2019

No comments. Closing.

@olegwtf olegwtf closed this as completed Nov 5, 2019
@Grinnz
Copy link
Contributor Author

Grinnz commented Nov 5, 2019

This can be tested in the mojo use case by patching Mojo::IOLoop::Client to add a threads_limit or threads_strict_limit on this line: https://metacpan.org/release/Mojolicious/source/lib/Mojo/IOLoop/Client.pm#L48

@Grinnz
Copy link
Contributor Author

Grinnz commented Nov 5, 2019

@daoswald can you test this?

@daoswald
Copy link

daoswald commented Nov 5, 2019 via email

@daoswald
Copy link

daoswald commented Nov 5, 2019 via email

@olegwtf
Copy link
Owner

olegwtf commented Nov 6, 2019

You need to increase number of allowed open files per process (ulimit -n). Each getaddrinfo() call creates 2 open handles independently of the way it will be processed: immediately or queued. I see no way to decrease number of open filehandles. Suggestions are welcome.

@olegwtf olegwtf reopened this Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants