[Twisted-Python] Throttling a web2 server

Cameron Dale camrdale at gmail.com
Tue Feb 26 15:12:22 EST 2008


Hi,

I'm relatively new to Twisted, and I was wondering if anyone has had
success with the ThrottlingFactory, or any other methods for
throttling push producers.

I'm attempting to throttle the bandwidth of the web2 server using the
twisted.protocols.policies.ThrottlingFactory. I know this isn't
possible with web1 (see Ticket #601), but it should be possible with
web2 since web2 uses a streaming (push) producer.

The trouble I'm having is that the ThrottlingFactory doesn't throttle
the server at all. I've traced the output, and it seems to be due to
the twisted.internet.tcp.Server also calling the pauseProducing() and
resumeProducing() methods of the producer.

The way the ThrottlingFactory works, is that it schedules periodic
checks of the number of bytes written using reactor.callLater. If too
many bytes have been written, then the producer is paused. However,
these periodic checks always occur when the producer is already paused
by the twisted.internet.tcp.Server, and so have no effect. Later the
producer is resumed by the twisted.internet.tcp.Server, and so the
throttling is non-existent.

Thanks,
Cameron




More information about the Twisted-Python mailing list