Twisted: graceful performance deteriorates in case of reactor overload?

How can one “detect” that the reactor is overloaded and starts to drop connections or refuse new connections? How can we avoid a complete reactor overload and not catch up?

+4
source share
3 answers

If I understand Twisted Reactors correctly, they do not parallelize everything. Regardless of which operations have been queued, it is planned and executed one by one.

One way for you is to create a custom addCallback that checks how many callbacks are already registered and, if necessary, is discarded.

+1
source

I would approach this protocol. Throttle when it requires actual maintenance, not when you think it will happen. Instead of worrying about how many callbacks the reactor ticker is waiting for, I’ll worry about how long the HTTP requests take (for example). The number of operations awaiting the reactor may be implementation details - for example, if one access pattern ends with callbacks on long lists of pending lists, and the other has a more linear chain of callbacks, the response time may not differ, although the number of callbacks will be.

This can be done by storing the time metric to complete the logical operation (for example, serving an HTTP request). The advantage of this is that it gives you important information before a problem occurs.

+1
source

All Articles