<br><br><div class="gmail_quote">On Sun, Jul 15, 2012 at 1:38 AM, Werner Thie <span dir="ltr">&lt;<a href="mailto:werner@thieprojects.ch" target="_blank">werner@thieprojects.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 7/14/12 12:39 AM, gelin yan wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Jul 11, 2012 at 2:08 AM, Werner Thie &lt;<a href="mailto:werner@thieprojects.ch">werner@thieprojects.ch</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:werner@thieprojects.ch">werner@thieprojects.ch</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     On 7/10/12 6:17 AM, Laurens Van Houtven wrote:<br>
&gt;      &gt; FWIW,  I have used Ampoule to great effect, but as JP points out<br>
&gt;     it&#39;s hardly the only option. You&#39;re bound to end up with some<br>
&gt;     measure of multiprocessing. Bear in mind that not all workloads are<br>
&gt;     well-suited for this kind of problem! Always measure before deciding<br>
&gt;     to make your codebase that much more complicated :)<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt; cheers<br>
&gt;      &gt; lvh<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt; On 10 Jul 2012, at 18:03, <a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a><br>
</div><div class="im">&gt;     &lt;mailto:<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt; wrote:<br>
&gt;      &gt;<br>
&gt;      &gt;&gt; On 03:14 pm, <a href="mailto:augustocaringi@gmail.com">augustocaringi@gmail.com</a><br>
</div><div><div class="h5">&gt;     &lt;mailto:<a href="mailto:augustocaringi@gmail.com">augustocaringi@gmail.com</a>&gt; wrote:<br>
&gt;      &gt;&gt;&gt; Hi,<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    I&#39;m researching the best way to implement/use a Twisted-based<br>
&gt;      &gt;&gt;&gt; server in a multicore environment...<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    There is the Ampoule project, that I realize is considered the<br>
&gt;      &gt;&gt;&gt; best way to do that. Right?<br>
&gt;      &gt;&gt;<br>
&gt;      &gt;&gt; It&#39;s a way.  &quot;Best&quot; depends on the details and goals of the project.<br>
&gt;      &gt;&gt;<br>
&gt;      &gt;&gt; Here&#39;s a stackoverflow question/answer on basically the same<br>
&gt;     topic.  In<br>
&gt;      &gt;&gt; particular, it specifically answers the question of a listening port<br>
&gt;      &gt;&gt; shared between multiple processes and gives examples of how to<br>
&gt;     do this:<br>
&gt;      &gt;&gt;<br>
&gt;      &gt;&gt; <a href="http://bit.ly/MiCHtQ" target="_blank">http://bit.ly/MiCHtQ</a><br>
&gt;      &gt;&gt;<br>
&gt;      &gt;&gt; Jean-Paul<br>
&gt;      &gt;&gt;&gt;    I&#39;m also reading about the internals of Nginx HTTP server. This<br>
&gt;      &gt;&gt;&gt; server utilizes the same reactor pattern of Twisted (epoll<br>
&gt;     based)...<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    &quot;What resulted is a modular, event-driven, asynchronous,<br>
&gt;      &gt;&gt;&gt; single-threaded, non-blocking architecture which became the<br>
&gt;     foundation<br>
&gt;      &gt;&gt;&gt; of nginx code.&quot; <a href="http://www.aosabook.org/en/nginx.html" target="_blank">http://www.aosabook.org/en/nginx.html</a><br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    But to maximize the use of processors in a multicore<br>
&gt;     environment,<br>
&gt;      &gt;&gt;&gt; Nginx do this:<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    &quot;nginx doesn&#39;t spawn a process or thread for every connection.<br>
&gt;      &gt;&gt;&gt; Instead, worker processes accept new requests from a shared<br>
&gt;     &quot;listen&quot;<br>
&gt;      &gt;&gt;&gt; socket and execute a highly efficient run-loop inside each<br>
&gt;     worker to<br>
&gt;      &gt;&gt;&gt; process thousands of connections per worker&quot;<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    My question: There is something similar in Twisted? Or do you<br>
&gt;      &gt;&gt;&gt; think that is easy to implement something like that?<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt;    Thanks!<br>
&gt;      &gt;&gt;&gt;<br>
&gt;      &gt;&gt;&gt; --<br>
&gt;      &gt;&gt;&gt; Augusto Mecking Caringi<br>
&gt;     We observed really great scaling on multi cores with moving the<br>
&gt;     application part either to ampoule for PDF production or in the other<br>
&gt;     case I wrote an implementation of self regulating process pool based on<br>
&gt;     spread, leaving only the serving to twisted in both cases.<br>
&gt;<br>
&gt;     With handing work out to other processes you get another benefit which<br>
&gt;     is isolation of python, which is the only way to use a package, like<br>
&gt;     reportlab which survives no sort of reentrancy, for a webservice.<br>
&gt;<br>
&gt;     Werner<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     Twisted-Python mailing list<br>
&gt;     <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
</div></div>&gt;     &lt;mailto:<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a>&gt;<br>
<div class="im">&gt;     <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
&gt;<br>
&gt; Hi Werner<br>
&gt;<br>
&gt;         I want to know whether you have experienced any serious bug with<br>
&gt; ampoule? What version of ampoule did you use? Is it 0.2.0? Thanks.<br>
<br>
</div>Hi gelin<br>
<br>
Python 2.7.1 Stackless 3.1b3 060516 (release27-maint, Aug  9 2011,<br>
02:32:21)<br>
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8<br>
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
 &gt;&gt;&gt; import ampoule<br>
 &gt;&gt;&gt; ampoule.__version__<br>
&#39;0.2.0&#39;<br>
 &gt;&gt;&gt; import twisted<br>
 &gt;&gt;&gt; twisted.__version__<br>
&#39;12.0.0&#39;<br>
<br>
sitting in production now for almost six month, a webservice for<br>
template based PDF production with reportlab &amp; z3c.rml.<br>
<br>
The only maintenance I do is creating more templates, never done a<br>
restart so far, logs are clean.<br>
<br>
As painless as one could wish for<br>
<div class="HOEnZb"><div class="h5"><br>
Werner<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>Hi Werner<br><br>     Thanks for your valuable info. It looks like you are using stackless python with twisted. Have you taken any benefit from both of them? Stackless is awesome but I have no idea what is the better way to work with twisted. Thanks.<br>
<br>Regards<br><br>gelin yan<br>