From: Mike Li <mik...@ya...> - 2003-05-22 23:35:54
|
NIO is easier to work on for simple application, but is more complicated for large application, which is also a reason that most of HTTP servers, like Apache, still uses multi-thread context switching model. In a complicated server, like HTTP server, multi-thread is always necessary. However, NIO can be used to minimize the number of threads and to reduce the overhead of thread context switching. The use of threads in NIO server may be in a different way, for example, thread may be designed to based on per task, not per request. Another benefit from using NIO is that the context swiching can be done at application level, not TCP/IP stack level. In application level, you can always have more control to reduct the overhead of thread context switching. It sounds great so far, but how to design a thread model to fit all you need is harder. If you have any idea about NIO and multi-thread, please post here. Mike. >>If an external applications hold the connection open the non-blocking IO >>library will return immediately with 0 bytes on a read() therefore the single >>thread is free to continue processing other requests. >> >> > > >You mean if there isnt any data to send we just iterate through the >loop again and check in the next round whether there is data waiting? >This would work, however it seems it would be rather difficult to >understand such a code as it would need many lists to keep track of >active connections with their associations to running applications. We >would need to split every outgoing data (regular files and CGI data) >into small pieces which would need to be transferred individually in >order to prevent that blocking. > >Does anyone have comments to that? > >Alexander > > > >------------------------------------------------------- >This SF.net email is sponsored by: ObjectStore. >If flattening out C++ or Java code to make your application fit in a >relational database is painful, don't do it! Check out ObjectStore. >Now part of Progress Software. http://www.objectstore.net/sourceforge >_______________________________________________ >insomnia-httpd-devel mailing list >ins...@li... >https://lists.sourceforge.net/lists/listinfo/insomnia-httpd-devel >. > > > |