c2523f52   
   XPost: comp.arch.embedded, comp.os.linux.networking   
   From: barmar@alum.mit.edu   
      
   In article   
   <597a7568-ddf4-43af-bff0-fb22d0dddb37@m35g2000prh.googlegroups.com>,   
    karthikbalaguru wrote:   
      
   > While reading about the various designs, interestingly i   
   > came across an info that the design of TCP servers is   
   > mostly such that whenever it accepts a connection,   
   > a new process is invoked to handle it .   
   > But, it seems that in the case of UDP servers design,   
   > there is only a single process that handles all client   
   > requests. Why such a difference in design of TCP and   
   > UDP servers ? How is TCP server able to handle   
   > large number of very rapid near-simultaneous connections ?   
   > Any ideas ?   
      
   TCP is usually used for services that require a large amount of   
   interaction between the client and server, and state that must be   
   maintained for the duration of the connection. Forking a process or   
   spawning a thread provides an easy way to maintain that state, and keep   
   other connections from interfering. And since the connection is likely   
   to be maintained for a significant period of time, the overhead of   
   forking a process is usually negligible.   
      
   UDP is generally used for simple request/response protocols, where each   
   packet is independent and state doesn't need to be maintained. Speed is   
   often of the essense, so having to fork a process for each request would   
   slow things down noticeably.   
      
   There are exceptions, though. If a server handles hundreds or thousands   
   of concurrent connections, forking so many processes is likely to   
   overload the system. Thread pools are often used for these types of   
   servers.   
      
   --   
   Barry Margolin, barmar@alum.mit.edu   
   Arlington, MA   
   *** PLEASE post questions in newsgroups, not directly to me ***   
   *** PLEASE don't copy me on replies, I'll read them in the group ***   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|