3 ms·
Not exactly related to Go/PyPy, but I'm curious whether you can say something about how you handle memory and bandwidth constraints? E.g. what do you do if you
by Matthias247 11y ago
Not exactly related to Go/PyPy, but I'm curious whether you can say something about how you handle memory and bandwidth constraints?
E.g. what do you do if you want to send notifications to lots of clients but for some the connection is very slow (you would probably need to buffer the data)? Do you have hard limits of maximum buffered data until you close the connection? End to end backpressure (for which channels are quite good) doesn't seem like the best option for 1:N broadcasts, because then the slowest receiver slows down all others.
And what do you do with connections which are sending you lots of (probably unexcepted) data? Stop reading from that socket?
- windlep 11y agoWe're using twisted, but I believe Python 3's asyncio has a similar feature with use of non-blocking sockets, which is that you can add a hook to be triggered when too much data accumulates in user-space (can't be flushed to the kernel's tcp buffer). In our case, when notifications buffer for a slow client, this API gets triggered and we mark the client connection as 'paused'. Until that state is cleared by more data getting to the client, notifications go to the database instead with just a flag on the client connection to check the db when the pending data was retrieved. We do a similar thing on the receiving end to pause reading off the socket if we're already doing more work on behalf of the client at once than desired. twisted documents this as producer/consumer: http://twisted.readthedocs.org/en/twisted-15.4.0/core/howto/producers.html http://twisted.readthedocs.org/en/twisted-15.4.0/core/howto/...