[Stackless] Stackless Twisted Integration Example

Carlos Eduardo de Paula cedepaula at yahoo.com.br
Mon Feb 26 22:44:36 CET 2007

Hey Andrew,

Its a very nice approach the integration you made of stackless and twisted. 

I played a little with twisted some weeks ago, more focused on the perspective broker module. Its a great way for doing remote method calls almost transparently.

I even submitted a patch for analysis which adds support for anonymous login access into its authentication scheme.

I will think in an example merging your integration but using twisted PB that in my opinion is one of the best features in twisted.

My current computer is a Pentium 4 2.8Ghz, the only changes I made to your code is adding the sleep call in tick. For testing, I wrote a small bit like this:

import urllib
import time
import socket

end = 0
count = 0

def test():
    global count, end
    start = time.time()
    for i in xrange(200):
        urlopener = urllib.URLopener()
        res = urlopener.open(r'http://localhost:8000/')
        count += 1
    end = time.time() - start

print "Ended with ", count, " transactions, ", count / end, " TPS"
I got around 60 TPS... to check if the bottleneck was in the "client" i wrote a threaded one and got the same results with many threads.

Whats interesting is that I always get around 60-65 TPS but my CPU usage is extremely low.. the server process uses less then 1%, I think there´s something limiting inside the server.

I will try to read some documentation on twisted side also... may we could get better performance having the server spawn a new tasklet handler for each incoming connection, then it would open a CGI tasklet also and the server would perform better. I will give it a try... need to study some more twisted...

As I do more tests, I keep you informed, any suggestion is welcome.


----- Original Message ----
From: Andrew Francis <andrewfr_ice at yahoo.com>
To: Carlos Eduardo de Paula <cedepaula at yahoo.com.br>; Stackless mailing list <stackless at stackless.com>
Cc: Andrew Francis <andrewfr_ice at yahoo.com>
Sent: Monday, February 26, 2007 5:57:19 PM
Subject: Re: [Stackless] Stackless Twisted Integration Example

Hello Carlos:

--- Carlos Eduardo de Paula <cedepaula at yahoo.com.br>

> Testing the threaded approach, looks like that if
> you do too many reloads (can be done in the browser
> itself), the server stops responding.

Out of curiousity, how much is too many?  Also what
sort of processor/OS? Also does the server eventually
catch up? So far I have just tried reloading through
the browser. I should write an automated test.

> It seems that the tick is taking too much 
>processor in its busy wait.

Yes it is a tight poll. It is there for illustrative

> I added a call to time.sleep(0.001) inside
> Tick loop and it seem much more responsive to the
> requests.

> I will try to test how many transactions per second
> it can handle.

Thanks, we can compare notes. So far do you have any
additional comments about the approach?


Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.

Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list