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

Use thread pool instead of new thread per request #30

Merged
merged 1 commit into from
Oct 10, 2019

Conversation

ionut-arm
Copy link
Member

Added a threadpool to handle our requests instead of spinning up a new thread per request which would allow a DoS.

Resolves #29.

Copy link
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so good how easy it is 😃
I guess in the future the thread pool size will be set in the configuration?

@ionut-arm
Copy link
Member Author

It's so good how easy it is 😃
I guess in the future the thread pool size will be set in the configuration?

Yes, I'd think so, the admin can judge by themselves and maybe we should stick with ncpus for the default value?

@hug-dev
Copy link
Member

hug-dev commented Oct 10, 2019

I think using the number of CPUs is a good idea, there is this crate for that: https://github.com/seanmonstar/num_cpus

@ionut-arm
Copy link
Member Author

threadpool actually uses that crate under the hood and the Builder uses the number of CPUs as a default if you don't specify a value :)

This commit adds a thread pool to which all requests will be dispatched
instead of creating a new thread for each request.

Changes provided by:
* Ionut Mihalcea (ionut.mihalcea@arm.com)
* Hugues de Valon (hugues.devalon@arm.com)

Change-Id: Ib8dc4fab3694d26a71f3f7b4c98b14dbc934d601
Signed-off-by: Ionut Mihalcea <ionut.mihalcea@arm.com>
@ionut-arm ionut-arm merged commit 051cdde into parallaxsecond:master Oct 10, 2019
@ionut-arm ionut-arm deleted the threadpool branch October 10, 2019 15:40
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

Successfully merging this pull request may close these issues.

Implement a thread pool
2 participants