Skip to content

gevent_uwsgi use more cpu #230

@youyueyinfeng

Description

@youyueyinfeng

HI, I'm testing the performance between gevent_uwsgi and gevent. The test case is 5000 connection only send PING/PONG.

The result is that gevent_uwsgi use almost twice cpu than gevent. I modify the self._event.wait(timeout) in curious, and then gevent_uwsgi use almost same cpu as gevent.

def wait(self):
        """Waits and returns received messages.
        If running in compatibility mode for older uWSGI versions,
        it also sends messages that have been queued by send().
        A return value of None means that connection was closed.
        This must be called repeatedly. For uWSGI < 2.1.x it must
        be called from the main greenlet."""
        while True:
            if self._req_ctx is not None:
                try:
                    msg = uwsgi.websocket_recv(request_context=self._req_ctx)
                except IOError:  # connection closed
                    return None
                return self._decode_received(msg)
            else:
                # we wake up at least every 3 seconds to let uWSGI
                # do its ping/ponging
                # ---- HERE. I changed the timeout  -----
                event_set = self._event.wait(timeout=3*1000000)
                ....

The uwsgi version I used is 2.0.19.1, the latest version in pypip, which is also the latest version in uwsgi documentation. So the gevent_uwsgi will wake up every 3 seconds. The comment said that it wake up for uwsgi ping/pong. But I don't understand why engineio need do uwsgi ping/pong again, since it already did its ping/pong. Is it because the uwsgi default config websocket-ping-freq and websocket-pong-tolerance ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions