[Twisted-Python] why is Twsited efficiently in one thread? what about in multi-processor system?

hi all, I read a text about twisted vs thread, who can tell mewhy Twsited is efficiently in one thread? especially, if clients require long-running processing above and beyond socket calls, or in the multi-processor system? look at this: http://kaishaku.org/twisted-vs-threads/ -- eSX

On 8/15/07, Yan Zhu <nayuhz@gmail.com> wrote:
hi all, I read a text about twisted vs thread, who can tell mewhy Twsited is efficiently in one thread? especially, if clients require long-running processing above and beyond socket calls, or in the multi-processor system? look at this: http://kaishaku.org/twisted-vs-threads/
I recommend twisted.internet.threads.deferToThread. Hope this helps, -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/

Hi, I think that your question can be answered in three parts: 1. who can tell me why Twsited is efficiently in one thread? Assuming your "one thread" is actually referring to the Twisted reactor thread handling IO event, you can take a look at a good Java One 2007 Tech Session "Tricks and Tips With NIO Using the Grizzly Framework" at: http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2992&yr=2007&track=5 "Tip #6: To Thread or not to Thread" started from Slide 61 actually tells you which threading model has the best performance based on the the benchmark did by Sun People. Since both Java NIO and Python Twisted actually utilize the same Socket Select/Poll mechanism for Non-blocking Network IO, hopefully this presentation will answer your "one thread" question. 2. What is a fair benchmark for Non-blocking Networking Framework? Any Non-blocking Networking Framework is at least trying to resolve the Scalability Problem occurred when a server has high volume concurrent network connections from hundreds and thousands of clients. Usually, a good Non-blocking Networking Benchmark should measure how a server will perform when the number of opened connections is increasing from 100 to 1000 to ... If you really want to find a good benchmark to measure the Non-blocking Network Framework, you can take a look at a good blog entry "Apache Mina and Twisted Matrix benchmarks" at: http://blog.bluendo.com/ff/mina-and-twisted-matrix-benchmarks ( Note: Apache Mina is a Java NIO Application Framework ) 3. What about in multi-processor system? Since Twisted does support reactor thread pool, this actually is more general question: how python threading module will utilize/ benefit from the multi-core processor system? And, you should be able to find plenty discussion at Python Mailing list, such as "Dual Core outlook" at: http://mail.python.org/pipermail/python-list/2006-February/366002.html My three cents:-). Jian On 8/15/07, Yan Zhu <nayuhz@gmail.com> wrote:
hi all, I read a text about twisted vs thread, who can tell mewhy Twsited is efficiently in one thread? especially, if clients require long-running processing above and beyond socket calls, or in the multi-processor system? look at this: http://kaishaku.org/twisted-vs-threads/
-- eSX _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (3)
-
Christopher Armstrong
-
jian wu
-
Yan Zhu