eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

When set thread pool size to >1, but CPU usage only 25 #201

Closed chenzx closed 6 years ago

chenzx commented 6 years ago

When set thread pool size to >1, but CPU usage only 25, means these threads are all running on a single hard cpu core?

''' HttpServer server; server.config.port = 9999; server.config.reuse_address = true; server.config.thread_pool_size = 5; server.config.timeout_request = 300; server.config.timeout_content = 600; '''

chenzx commented 6 years ago

I see it in Window's process manager,

In Performance > CPU Usage, all 4 cpu cores seem active,

But in Process > "CPU" column, the value is at most 25.

eidheim commented 6 years ago

Multiple threads can run on one core, but if two threads is executing tasks simultaneously, they would need 2 cores.

Your CPU usage would depend on Asio internals and the load of the server. Other than that you are on your own here, at least I am of no more help I think, especially on Windows.

chenzx commented 6 years ago

Thanks for rely. After i use python scripts to do concurrent requests, the CPU usage now goes to >25. So it's due to previous sequential requests.

2018-01-17 19:30 GMT+08:00 Ole Christian Eidheim notifications@github.com:

Multiple threads can run on one core, but if two threads is executing tasks simultaneously, they would need 2 cores.

Your CPU usage would depend on Asio internals and the load of the server. Other than that you are on your own here, at least I am of no more help I think, especially on Windows.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eidheim/Simple-Web-Server/issues/201#issuecomment-358277435, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmBT38wDg7ZwsaTVV6uL8qaxwJTajSuks5tLdnwgaJpZM4RhD_K .