CherryPy and concurrency

2019-02-16 01:29发布

问题:

I'm using CherryPy in order to serve a python application through WSGI.

I tried benchmarking it, but it seems as if CherryPy can only handle exactly 10 req/sec. No matter what I do.

Built a simple app with a 3 second pause, in order to accurately determine what is going on... and I can confirm that the 10 req/sec has nothing to do with the resources used by the python script.

__

Any ideas?

回答1:

By default, CherryPy's builtin HTTP server will use a thread pool with 10 threads. If you are still using the defaults, you could try increasing this in your config file.

[global]
server.thread_pool = 30
  • See the cpserver documentation
  • Or the archive.org copy of the old documentation


回答2:

Your client needs to actually READ the server's response. Otherwise the socket/thread will stay open/running until timeout and garbage collected.

use a client that behaves correctly and you'll see that your server will behave too.