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

Will heavy database query make one of cpu cores idle? #18

Open
art-in opened this issue Dec 10, 2019 · 3 comments
Open

Will heavy database query make one of cpu cores idle? #18

art-in opened this issue Dec 10, 2019 · 3 comments

Comments

@art-in
Copy link

art-in commented Dec 10, 2019

Hi, I'm trying to figure this out, since apparently diesel doesn't support async (nor underlying postgres driver).

You're not explicitly specifying number of workers for HttpServer, which means it will create (number of cpu cores)-threads for handling incoming http requests.

Now, when next http request runs heavy database query through diesel it will block current thread. And for example, if my system has 4 cpu cores, it's enough to run 4 heavy http requests simultaneously to completely DoS entire server.

Is that correct?

@vadixidav
Copy link

@art-in I am not the author, but this thing is not using actix 2.0 (currently in release candidate). It is using a pre 1.0 actix. The db call does not spawn a new task, and is blocking (see here). I do not believe that this app is what you should be looking at if you want to use async actix. I would recommend looking here: https://github.com/actix/examples.

@art-in
Copy link
Author

art-in commented Dec 12, 2019

@vadixidav So in this example I see that database query is wrapped into web::block(), which run queries on a thread pool while not blocking main http server workers pool.

But web::block() available even in currently released v1.0.9

Probably this project should use this approach too?..

@vadixidav
Copy link

@art-in Most likely, but I have only started using Actix with std::future support.

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

2 participants