<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Asynchronous Servers in Python</title> <atom:link href="http://nichol.as/asynchronous-servers-in-python/feed" rel="self" type="application/rss+xml" /><link>http://nichol.as/asynchronous-servers-in-python</link> <description></description> <lastBuildDate>Thu, 29 Jul 2010 06:07:23 +0200</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Tom Burdick</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-5375</link> <dc:creator>Tom Burdick</dc:creator> <pubDate>Sun, 18 Jul 2010 18:07:53 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-5375</guid> <description>Just as a quick comparison I created a client based around pyev, here is the program[py]
import socket
import signal
import pyevclass Client(object):
def start(self, loop, sock):
self.msg = &quot;HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n&quot;
self.sock = sock
self.write = self.write_msg
self.writewatcher = pyev.Io(self.sock, pyev.EV_WRITE, loop, self.write)
self.writewatcher.start()def write_msg(self, watcher, events):
self.sock.send(self.msg)
self.writewatcher.stop()
self.sock.close()class Server(object):
def start(self, loop):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.bind((&#039;localhost&#039;, 10000))
self.sock.listen(500)
self.acceptwatcher = pyev.Io(self.sock, pyev.EV_READ, loop, self.accept)
self.acceptwatcher.start()def accept(self, watcher, events):
(sock, addr) = self.sock.accept()
client = Client()
client.start(watcher.loop, sock)def interrupt(watcher, events):
watcher.loop.unloop()loop = pyev.default_loop()
sigwatch = pyev.Signal(signal.SIGINT, loop, interrupt)
sigwatch.start()
srv = Server()
srv.start(loop)
loop.loop()
[/py]Here is the results using ra=10000&lt;blockquote&gt;httperf --hog --server localhost --num-conn 40000 --port 10000 --ra 10000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=10000 --uri=/ --rate=10000 --send-buffer=4096 --recv-buffer=16384 --num-conns=40000 --num-calls=1
Maximum connect burst length: 41Total: connections 40000 requests 40000 replies 40000 test-duration 3.997 sConnection rate: 10008.5 conn/s (0.1 ms/conn, &lt;=57 concurrent connections)
Connection time [ms]: min 0.1 avg 0.3 max 4.5 median 0.5 stddev 0.2
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 1.000Request rate: 10008.5 req/s (0.1 ms/req)
Request size [B]: 62.0Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.2 transfer 0.0
Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)
Reply status: 1xx=0 2xx=40000 3xx=0 4xx=0 5xx=0CPU time [s]: user 1.19 system 2.79 (user 29.9% system 69.9% total 99.7%)
Net I/O: 1026.3 KB/s (8.4*10^6 bps)Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
&lt;/blockquote&gt;Note that the sockets are in fact blocking, I never set nonblocking, I have no doubt I could do even better with nonblocking.If this bench is saying anything, its saying nothing comes even close to pyev in the python world, nothing.Just to really push things, I tried 20k per second...&lt;blockquote&gt;httperf --hog --server localhost --num-conn 40000 --port 10000 --ra 20000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=10000 --uri=/ --rate=20000 --send-buffer=4096 --recv-buffer=16384 --num-conns=40000 --num-calls=1
Maximum connect burst length: 33Total: connections 40000 requests 40000 replies 40000 test-duration 2.004 sConnection rate: 19963.5 conn/s (0.1 ms/conn, &lt;=56 concurrent connections)
Connection time [ms]: min 0.1 avg 0.5 max 2.7 median 0.5 stddev 0.2
Connection time [ms]: connect 0.3
Connection length [replies/conn]: 1.000Request rate: 19963.5 req/s (0.1 ms/req)
Request size [B]: 62.0Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.3 transfer 0.0
Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)
Reply status: 1xx=0 2xx=40000 3xx=0 4xx=0 5xx=0CPU time [s]: user 0.35 system 1.64 (user 17.6% system 81.8% total 99.5%)
Net I/O: 2047.0 KB/s (16.8*10^6 bps)Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0&lt;/blockquote&gt;And finally how the twisted example does on my machine in comparison, exactly as taken from this blog when given a rate of 10k...&lt;blockquote&gt;httperf --hog --server localhost --num-conn 40000 --port 10000 --ra 10000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=10000 --uri=/ --rate=10000 --send-buffer=4096 --recv-buffer=16384 --num-conns=40000 --num-calls=1
Maximum connect burst length: 16Total: connections 26269 requests 26269 replies 26269 test-duration 6.261 sConnection rate: 4195.4 conn/s (0.2 ms/conn, &lt;=1022 concurrent connections)
Connection time [ms]: min 0.5 avg 152.4 max 3162.8 median 116.5 stddev 305.9
Connection time [ms]: connect 31.7
Connection length [replies/conn]: 1.000Request rate: 4195.4 req/s (0.2 ms/req)
Request size [B]: 62.0Reply rate [replies/s]: min 5247.1 avg 5247.1 max 5247.1 stddev 0.0 (1 samples)
Reply time [ms]: response 120.7 transfer 0.0
Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)
Reply status: 1xx=0 2xx=26269 3xx=0 4xx=0 5xx=0CPU time [s]: user 0.24 system 6.00 (user 3.9% system 95.9% total 99.8%)
Net I/O: 430.2 KB/s (3.5*10^6 bps)Errors: total 13731 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 13731 addrunavail 0 ftab-full 0 other 0&lt;/blockquote&gt;It basically fails to even finish...</description> <content:encoded><![CDATA[<p>Just as a quick comparison I created a client based around pyev, here is the program</p><pre class="brush: python;">
import socket
import signal
import pyev

class Client(object):
    def start(self, loop, sock):
        self.msg = &quot;HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n&quot;
        self.sock = sock
        self.write = self.write_msg
        self.writewatcher = pyev.Io(self.sock, pyev.EV_WRITE, loop, self.write)
        self.writewatcher.start()

    def write_msg(self, watcher, events):
        self.sock.send(self.msg)
        self.writewatcher.stop()
        self.sock.close()

class Server(object):
    def start(self, loop):
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.bind(('localhost', 10000))
        self.sock.listen(500)
        self.acceptwatcher = pyev.Io(self.sock, pyev.EV_READ, loop, self.accept)
        self.acceptwatcher.start()

    def accept(self, watcher, events):
        (sock, addr) = self.sock.accept()
        client = Client()
        client.start(watcher.loop, sock)

def interrupt(watcher, events):
    watcher.loop.unloop()

loop = pyev.default_loop()
sigwatch = pyev.Signal(signal.SIGINT, loop, interrupt)
sigwatch.start()
srv = Server()
srv.start(loop)
loop.loop()
</pre><p>Here is the results using ra=10000</p><blockquote><p>httperf &#8211;hog &#8211;server localhost &#8211;num-conn 40000 &#8211;port 10000 &#8211;ra 10000 &#8211;timeout 5<br /> httperf &#8211;hog &#8211;timeout=5 &#8211;client=0/1 &#8211;server=localhost &#8211;port=10000 &#8211;uri=/ &#8211;rate=10000 &#8211;send-buffer=4096 &#8211;recv-buffer=16384 &#8211;num-conns=40000 &#8211;num-calls=1<br /> Maximum connect burst length: 41</p><p>Total: connections 40000 requests 40000 replies 40000 test-duration 3.997 s</p><p>Connection rate: 10008.5 conn/s (0.1 ms/conn, &lt;=57 concurrent connections)<br /> Connection time [ms]: min 0.1 avg 0.3 max 4.5 median 0.5 stddev 0.2<br /> Connection time [ms]: connect 0.1<br /> Connection length [replies/conn]: 1.000</p><p>Request rate: 10008.5 req/s (0.1 ms/req)<br /> Request size [B]: 62.0</p><p>Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)<br /> Reply time [ms]: response 0.2 transfer 0.0<br /> Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)<br /> Reply status: 1xx=0 2xx=40000 3xx=0 4xx=0 5xx=0</p><p>CPU time [s]: user 1.19 system 2.79 (user 29.9% system 69.9% total 99.7%)<br /> Net I/O: 1026.3 KB/s (8.4*10^6 bps)</p><p>Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0<br /> Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0</p></blockquote><p>Note that the sockets are in fact blocking, I never set nonblocking, I have no doubt I could do even better with nonblocking.</p><p>If this bench is saying anything, its saying nothing comes even close to pyev in the python world, nothing.</p><p>Just to really push things, I tried 20k per second&#8230;</p><blockquote><p>httperf &#8211;hog &#8211;server localhost &#8211;num-conn 40000 &#8211;port 10000 &#8211;ra 20000 &#8211;timeout 5<br /> httperf &#8211;hog &#8211;timeout=5 &#8211;client=0/1 &#8211;server=localhost &#8211;port=10000 &#8211;uri=/ &#8211;rate=20000 &#8211;send-buffer=4096 &#8211;recv-buffer=16384 &#8211;num-conns=40000 &#8211;num-calls=1<br /> Maximum connect burst length: 33</p><p>Total: connections 40000 requests 40000 replies 40000 test-duration 2.004 s</p><p>Connection rate: 19963.5 conn/s (0.1 ms/conn, &lt;=56 concurrent connections)<br /> Connection time [ms]: min 0.1 avg 0.5 max 2.7 median 0.5 stddev 0.2<br /> Connection time [ms]: connect 0.3<br /> Connection length [replies/conn]: 1.000</p><p>Request rate: 19963.5 req/s (0.1 ms/req)<br /> Request size [B]: 62.0</p><p>Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)<br /> Reply time [ms]: response 0.3 transfer 0.0<br /> Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)<br /> Reply status: 1xx=0 2xx=40000 3xx=0 4xx=0 5xx=0</p><p>CPU time [s]: user 0.35 system 1.64 (user 17.6% system 81.8% total 99.5%)<br /> Net I/O: 2047.0 KB/s (16.8*10^6 bps)</p><p>Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0<br /> Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0</p></blockquote><p>And finally how the twisted example does on my machine in comparison, exactly as taken from this blog when given a rate of 10k&#8230;</p><blockquote><p>httperf &#8211;hog &#8211;server localhost &#8211;num-conn 40000 &#8211;port 10000 &#8211;ra 10000 &#8211;timeout 5<br /> httperf &#8211;hog &#8211;timeout=5 &#8211;client=0/1 &#8211;server=localhost &#8211;port=10000 &#8211;uri=/ &#8211;rate=10000 &#8211;send-buffer=4096 &#8211;recv-buffer=16384 &#8211;num-conns=40000 &#8211;num-calls=1<br /> Maximum connect burst length: 16</p><p>Total: connections 26269 requests 26269 replies 26269 test-duration 6.261 s</p><p>Connection rate: 4195.4 conn/s (0.2 ms/conn, &lt;=1022 concurrent connections)<br /> Connection time [ms]: min 0.5 avg 152.4 max 3162.8 median 116.5 stddev 305.9<br /> Connection time [ms]: connect 31.7<br /> Connection length [replies/conn]: 1.000</p><p>Request rate: 4195.4 req/s (0.2 ms/req)<br /> Request size [B]: 62.0</p><p>Reply rate [replies/s]: min 5247.1 avg 5247.1 max 5247.1 stddev 0.0 (1 samples)<br /> Reply time [ms]: response 120.7 transfer 0.0<br /> Reply size [B]: header 38.0 content 5.0 footer 0.0 (total 43.0)<br /> Reply status: 1xx=0 2xx=26269 3xx=0 4xx=0 5xx=0</p><p>CPU time [s]: user 0.24 system 6.00 (user 3.9% system 95.9% total 99.8%)<br /> Net I/O: 430.2 KB/s (3.5*10^6 bps)</p><p>Errors: total 13731 client-timo 0 socket-timo 0 connrefused 0 connreset 0<br /> Errors: fd-unavail 13731 addrunavail 0 ftab-full 0 other 0</p></blockquote><p>It basically fails to even finish&#8230;</p> ]]></content:encoded> </item> <item><title>By: Péter Szabó</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-2592</link> <dc:creator>Péter Szabó</dc:creator> <pubDate>Mon, 17 May 2010 22:19:20 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-2592</guid> <description>Great, informative article!FYI Syncess, a high performance asynchronous client and server library using Stackless Python has born after this comparison. See Syncless at http://code.google.com/p/syncless/I&#039;ve also written a feature comparison of event-driven and coroutine-based non-blocking I/O libraries for Python. Read it at: http://ptspts.blogspot.com/2010/05/feature-comparison-of-python-non.html</description> <content:encoded><![CDATA[<p>Great, informative article!</p><p>FYI Syncess, a high performance asynchronous client and server library using Stackless Python has born after this comparison. See Syncless at <a href="http://code.google.com/p/syncless/" rel="nofollow">http://code.google.com/p/syncless/</a></p><p>I&#8217;ve also written a feature comparison of event-driven and coroutine-based non-blocking I/O libraries for Python. Read it at: <a href="http://ptspts.blogspot.com/2010/05/feature-comparison-of-python-non.html" rel="nofollow">http://ptspts.blogspot.com/2010/05/feature-comparison-of-python-non.html</a></p> ]]></content:encoded> </item> <item><title>By: Jason</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-2193</link> <dc:creator>Jason</dc:creator> <pubDate>Thu, 22 Apr 2010 21:41:55 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-2193</guid> <description>This is excellent research. I&#039;m currently looking for an async framework and I hadn&#039;t even heard of gevent. Thank you for putting this together and publishing it.</description> <content:encoded><![CDATA[<p>This is excellent research. I&#8217;m currently looking for an async framework and I hadn&#8217;t even heard of gevent. Thank you for putting this together and publishing it.</p> ]]></content:encoded> </item> <item><title>By: Jordan Fung</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-701</link> <dc:creator>Jordan Fung</dc:creator> <pubDate>Wed, 10 Mar 2010 03:30:26 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-701</guid> <description>I&#039;m using gevent.http to rewrite your test code and get 70% faster  :) , gevent is soooooooo cool!</description> <content:encoded><![CDATA[<p>I&#8217;m using gevent.http to rewrite your test code and get 70% faster <img src='http://nichol.as/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , gevent is soooooooo cool!</p> ]]></content:encoded> </item> <item><title>By: Why gevent &#171; Concurrency in Python</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-416</link> <dc:creator>Why gevent &#171; Concurrency in Python</dc:creator> <pubDate>Sat, 27 Feb 2010 15:04:49 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-416</guid> <description>[...] The superior performance is not the only benefit of tight integration with libevent. Other benefits are [...]</description> <content:encoded><![CDATA[<p>[...] The superior performance is not the only benefit of tight integration with libevent. Other benefits are [...]</p> ]]></content:encoded> </item> <item><title>By: Francisco Ribeiro</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-406</link> <dc:creator>Francisco Ribeiro</dc:creator> <pubDate>Wed, 17 Feb 2010 16:55:29 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-406</guid> <description>Nice post.Kamaelia project is missing.</description> <content:encoded><![CDATA[<p>Nice post.</p><p>Kamaelia project is missing.</p> ]]></content:encoded> </item> <item><title>By: Ryan Williams</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-405</link> <dc:creator>Ryan Williams</dc:creator> <pubDate>Wed, 17 Feb 2010 07:45:59 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-405</guid> <description>Hi there, just poking you to see whether you&#039;re going to update these with the corrected code that all the maintainers of these libraries have posted.  You said you&#039;d get to it &quot;somewhere after xmas&quot;....it&#039;s definitely after xmas!</description> <content:encoded><![CDATA[<p>Hi there, just poking you to see whether you&#8217;re going to update these with the corrected code that all the maintainers of these libraries have posted.  You said you&#8217;d get to it &#8220;somewhere after xmas&#8221;&#8230;.it&#8217;s definitely after xmas!</p> ]]></content:encoded> </item> <item><title>By: Integrate Tornado in Django — geek scrap</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-397</link> <dc:creator>Integrate Tornado in Django — geek scrap</dc:creator> <pubDate>Thu, 11 Feb 2010 00:38:08 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-397</guid> <description>[...] For more performance info, James Abley pointed me to a very complete benchmark of available Python asynchronous webservers. It looks like Tornado is a real monster of [...]</description> <content:encoded><![CDATA[<p>[...] For more performance info, James Abley pointed me to a very complete benchmark of available Python asynchronous webservers. It looks like Tornado is a real monster of [...]</p> ]]></content:encoded> </item> <item><title>By: Shannon -jj Behrens</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-396</link> <dc:creator>Shannon -jj Behrens</dc:creator> <pubDate>Wed, 10 Feb 2010 19:04:43 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-396</guid> <description>I can&#039;t thank you enough for writing this awesome blog post.  I recently gave a talk about Python concurrency, http://jjinux.blogspot.com/2009/12/python-concurrency.html, but I think I like your blog post even better since it shows the hard data and real code.</description> <content:encoded><![CDATA[<p>I can&#8217;t thank you enough for writing this awesome blog post.  I recently gave a talk about Python concurrency, <a href="http://jjinux.blogspot.com/2009/12/python-concurrency.html" rel="nofollow">http://jjinux.blogspot.com/2009/12/python-concurrency.html</a>, but I think I like your blog post even better since it shows the hard data and real code.</p> ]]></content:encoded> </item> <item><title>By: Bill Janssen</title><link>http://nichol.as/asynchronous-servers-in-python/comment-page-1#comment-393</link> <dc:creator>Bill Janssen</dc:creator> <pubDate>Mon, 08 Feb 2010 21:29:03 +0000</pubDate> <guid isPermaLink="false">http://nichol.as/?p=337#comment-393</guid> <description>Thanks for doing this!  I&#039;d be interested in the Medusa results -- that&#039;s what I&#039;m currently using for UpLib (http://uplib.parc.com/).  I keep wondering if I should shift to something else, but so far Medusa seems to keep working just fine.The current Medusa is at http://www.amk.ca/python/code/medusa.html.</description> <content:encoded><![CDATA[<p>Thanks for doing this!  I&#8217;d be interested in the Medusa results &#8212; that&#8217;s what I&#8217;m currently using for UpLib (<a href="http://uplib.parc.com/" rel="nofollow">http://uplib.parc.com/</a>).  I keep wondering if I should shift to something else, but so far Medusa seems to keep working just fine.</p><p>The current Medusa is at <a href="http://www.amk.ca/python/code/medusa.html" rel="nofollow">http://www.amk.ca/python/code/medusa.html</a>.</p> ]]></content:encoded> </item> </channel> </rss>