@@ -168,6 +168,7 @@ <h3 class="author">
168168< li > < a href ="#gevent-zeromq "> Gevent ZeroMQ</ a > </ li >
169169< li > < a href ="#simple-telnet-servers "> Simple Telnet Servers</ a > </ li >
170170< li > < a href ="#wsgi-servers "> WSGI Servers</ a > </ li >
171+ < li > < a href ="#streaming-servers "> Streaming Servers</ a > </ li >
171172< li > < a href ="#long-polling "> Long Polling</ a > </ li >
172173< li > < a href ="#websockets "> Websockets</ a > </ li >
173174< li > < a href ="#chat-server "> Chat Server</ a > </ li >
@@ -244,9 +245,8 @@ <h2 id="synchronous-asynchronous-execution">Synchronous & Asynchronous Execu
244245Explicit context switch to foo again
245246Implicit context switch back to bar
246247</ pre > </ code > </ p >
247- < p > It is illuminating to visualize the control of the program or
248- walk through it with a debugger to see the context switches as
249- they occur.</ p >
248+ < p > It is illuminating to visualize the control flow of the program or walk
249+ through it with a debugger to see the context switches as they occur.</ p >
250250< p > < img alt ="Greenlet Control Flow " src ="flow.gif " /> </ p >
251251< p > The real power of gevent comes when we use it for network and IO
252252bound functions which can be cooperatively scheduled. Gevent has
@@ -338,16 +338,16 @@ <h2 id="synchronous-asynchronous-execution">Synchronous & Asynchronous Execu
338338Task 8 done
339339Task 9 done
340340Asynchronous:
341- Task 2 done
341+ Task 1 done
342342Task 6 done
343+ Task 5 done
344+ Task 0 done
345+ Task 9 done
343346Task 8 done
344- Task 3 done
345- Task 4 done
346347Task 7 done
347- Task 1 done
348- Task 9 done
349- Task 0 done
350- Task 5 done
348+ Task 4 done
349+ Task 3 done
350+ Task 2 done
351351</ pre > </ code > </ p >
352352< p > In the synchronous case all the tasks are run sequentially,
353353which results in the main programming < em > blocking</ em > (
@@ -1071,11 +1071,14 @@ <h2 id="wsgi-servers">WSGI Servers</h2>
10711071< li > gevent.wsgi.WSGIServer</ li >
10721072< li > gevent.pywsgi.WSGIServer</ li >
10731073</ ul >
1074- < p > wsgi is a Python bridge to libev's < em > very</ em > fast HTTP
1075- server. It does one job very well. Namely shoving content down a
1076- network pipe as fast as possible. It is however limited in
1077- certain HTTP features, the key one being lack chunked transfer
1078- encoding.</ p >
1074+ < p > In earlier versions of gevent before 1.0.x, gevent used libevent
1075+ instead of libev. Libevent included a fast HTTP server which was
1076+ used by gevent's < code > wsgi</ code > server. </ p >
1077+ < p > In gevent 1.0.x there is no http server included. Instead
1078+ < code > gevent.wsgi</ code > it is now an alias for the pure Python server in
1079+ < code > gevent.pywsgi</ code > .</ p >
1080+ < h2 id ="streaming-servers "> Streaming Servers</ h2 >
1081+ < p > < strong > If you are using gevent 1.0.x, this section does not apply</ strong > </ p >
10791082< p > For those familiar with streaming HTTP services, the core idea is
10801083that in the headers we do not specify a length of the content. We
10811084instead hold the connection open and flush chunks down the pipe,
@@ -1139,6 +1142,9 @@ <h2 id="wsgi-servers">WSGI Servers</h2>
11391142< p > But regardless, performance on Gevent servers is phenomenal
11401143compared to other Python servers. libev is a very vetted technology
11411144and its derivative servers are known to perform well at scale.</ p >
1145+ < p > To benchmark, try Apache Benchmark < code > ab</ code > or see this
1146+ < a href ="http://nichol.as/benchmark-of-python-web-servers "> Benchmark of Python WSGI Servers</ a >
1147+ for comparison with other servers.</ p >
11421148< pre >
11431149< code class ="shell "> $ ab -n 10000 -c 100 http://127.0.0.1:8000/
11441150</ code >
0 commit comments