[Twisted-Python] twisted performance and reactor choice

Jean-Paul Calderone exarkun at divmod.com
Tue Nov 14 14:10:58 EST 2006


On Tue, 14 Nov 2006 17:51:04 +0000 (GMT), Stéphane Brault <stephane_brault at yahoo.fr> wrote:
>Thanks Jean-Paul,
>
>my mistake ;-) I must confess that if I use twisted (and I must say I'm quite happy with it),
>I didn't have time to know it that well.

No problem. :)  Optimization is hard.

>Anyway, I was wondering if changing the reactor could
>help a little (my application runs on a debian sarge 3.1). In which case would the pollreactor
>be relevant or should I stick with the default one (selectreactor if I read the documentation right).

If the application is actually bottlenecked in select, then it might help
a little.  Fortunately, it's easy to test.  Just run:

  twistd --reactor poll ...

Or if you're not using twistd, add:

  from twisted.internet import pollreactor
  pollreactor.install()

To the beginning of your application.  That's all that's necessary to change
to a different reactor.

>I have a lot of simultaneous deferred at scheduled times (both database access using zalchemy
>and connections to external sites which can take some times). I know this might not be enough
>to make a decision, but any help would be welcomed.

Changing the reactor won't speed up Deferreds or threads, though, since
all the reactors have the same thread code.

Jean-Paul




More information about the Twisted-Python mailing list