The current implementation of long-polling creates a thread or a process per connection. This comes from the design of WSGI server (used: werkzeug or uwsgi). This has drawback because production ready server like uwsgi limit the number of thread or process and so this does not scale well to the point we had to disable it by default.
So we need a solution that is thread-less.
We see two options:
- Adding a separate server which will be thread-less. The first thought is to base it on asyncio. So it should be deployed separately and a reverse-proxy should be configured to dispatch the request between the two services.
- Allow to run trytond and replace thread/fork by greenlet by using gevent. So a single process could be run for both requests or one thread/fork process can be launched as usual and a second with gevent to process long-polling request (using a reverse-proxy).
The two options are not mutually exclusive but it is probably better to have one way to scale up long-polling.
Here are prototypes of both solution: