<div dir="ltr">Hi Carl<div><br></div><div>The only motivation to use multiple processes is to be able to parallelize blocking calls (since event driven handling is not useful)  In my case forward proxy is not a bottleneck, however when my code spawns multiple processes as per  <a href="http://stackoverflow.com/questions/10077745/twistedweb-on-multicore-multiprocessor">http://stackoverflow.com/questions/10077745/twistedweb-on-multicore-multiprocessor</a> </div><div>and I run multiple concurrent clients, I see that the server's processes are not efficiently utilized. Specifically, even if there are outstanding requests, one of the processes accepts requests lot more while other processes are idling. I was able to confirm this by printing the Process IDs of the processes which are handling request</div><div><br></div><div>This sort of imbalance could lead to underutilization of CPU - also discussed here <a href="https://lwn.net/Articles/542629/">https://lwn.net/Articles/542629/</a></div><div><br></div><div>Hence I was curious to know how Twisted multiprocessing works. It seems SO_REUSEPORT is not used within Twisted and as per Gavin's reply can be used "outside" of Twisted.</div><div><br></div><div><br></div><div><br></div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 10, 2015 at 5:42 PM, Carl Waldbieser <span dir="ltr"><<a href="mailto:cwaldbieser@gmail.com" target="_blank">cwaldbieser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>There is a twisted developer guide for communicating with child processes:  <a href="http://twistedmatrix.com/documents/current/core/howto/process.html" target="_blank">http://twistedmatrix.com/documents/current/core/howto/process.html</a></p>
<p>I'm not sure I understand why having multiple processes listen on the same socket is desirable in your case.  From reading the articles you linked to, it seems like it is only useful in the case where a forward proxy becomes a bottleneck.  Is that the case wirh your application?</p>
<p>Thanks,<br>
Carl Waldbieser</p>
<div class="gmail_quote"><div><div class="h5">On Jun 9, 2015 10:03 PM, "Sagar Dixit" <<a href="mailto:sagar.dixit@gmail.com" target="_blank">sagar.dixit@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi,<div><br></div><div>I am exploring Twisted Web for my RESTful application. My application is stateless and involves storing and retrieving objects based on Object-ID. This application will run on beefy (multicore, lots of memory) machine. However, not all APIs that the application issues to underlying storage are async and hence I cannot fully utilize Deferreds</div><div>Which means, there will some blocking calls and hence my primary interest is to use Twisted Web in multiprocessing mode</div><div><br></div><div>I came across <a href="http://stackoverflow.com/questions/10077745/twistedweb-on-multicore-multiprocessor" target="_blank">http://stackoverflow.com/questions/10077745/twistedweb-on-multicore-multiprocessor</a></div><div><br></div><div>However, I am not sure if it is the "correct" way of doing things.</div><div><br></div><div>Hence I had some questions around it:</div><div><br></div><div>1.  Is there an interface (similar to defertoThread) which allows me to execute a blocking call in a separate process ?</div><div><br></div><div>2. Does reactor synchronize access of all processes to the shared listen socket ?</div><div><br></div><div>3. Is there a sample code I can refer to  where the application is spawning subprocesses to handle HTTP requests ?</div><div><br></div><div><div>Thanks in advance!</div><div><br></div>
</div></div>
<br></div></div><span class="">_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com" target="_blank">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></span></blockquote></div>
<br>_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">ssdixit<br><br></div>
</div>