When doing some tests with flask-socketio (on uwsgi with gevent) we noticed that when adding more clients, cpu usage on the socketio process quickly goes to 85%. The weird thing is that it doesn't seem to matter if the clients are in active communication or just all idly waiting.
I used pyflame to analyze what is happening and it seems over 50% of the time is spend in server.py:_service_task most of which is in sleep() and the other part in check_ping_timeout. I was able to find some stackoverflow posts describing the same behavior for idle-wait loops, but the described solution there was to introduce sleep(), which _service_task already does.
This happened with 150 clients on a ec2 t3.small instance. Weird thing is though that it does not happen with 50 clients. (similar behaviour on larger instance type with around 300 clients)
Is this normal? My main issue is that it makes it hard to determine if the server is overloaded or not.