title: Efficient Overlapped I/O for a socket server
body: <p>Which of these two different models would be more efficient (consider thrashing, utilization of processor cache, overall desgn, everything, etc)?</p>
  
  <ol>
  <li><p>1 IOCP and spinning up X threads (where X is the number of processors the computer has). This would mean that my "server" would only have 1 IOCP (queue) for all requests and X Threads to serve/handle them. I have read many articles discussing the effeciency of this design. With this model I would have 1 listener that would also be associated to the IOCP. Lets assume that I could figure out how to keep the packets/requests synchronized.</p></li>
  <li><p>X IOCP (where X is the number of processors the computer has) and each IOCP has 1 thread. This would mean that each Processor has its own queue and 1 thread to serve/handle them. With this model I would have a separate Listener (not using IOCP) that would handle incomming connections and would assign the SOCKET to the proper IOCP (one of the X that were created). Lets assume that I could figure out the Load Balancing.</p></li>
  </ol>
  
  <p>Using an overly simplified analogy for the two designs (a bank):</p>
  
  <ol>
  <li><p>One line with several cashiers to hand the transactions. Each person is in the same line and each cashier takes the next available person in line.</p></li>
  <li><p>Each cashier has their own line and the people are "placed" into one of those lines</p></li>
  </ol>
  
  <p>Between these two designs, which one is more efficient. In each model the Overlapped I/O structures would be using VirtualAlloc with MEM_COMMIT (as opposed to "new") so the swap-file should not be an issue (no paging). Based on how it has been described to me, using VirtualAlloc with MEM_COMMIT, the memory is reserved and is not paged out. This would allow the SOCKETS to write the incomming data right to my buffers without going through intermediate layers. So I don't think thrashing should be a factor but I might be wrong.</p>
  
  <p>Someone was telling me that #2 would be more efficient but I have not heard of this model. Thanks in advance for your comments!</p>