title: Thread per connection vs Reactor pattern (with a thread pool)?
body: <p>I want to write a simple multiplayer game as part of my C++ learning project.</p>
  
  <p>So I thought, <em>since I am at it, I would like to do it</em> properly, <em>as opposed to just getting-it-done</em>.</p>
  
  <p>If I understood correctly: Apache uses a Thread-per-connection architecture, while nginx uses an event-loop and then dedicates a worker <a href="https://stackoverflow.com/a/4765013/553801">[x]</a> for the incoming connection. I guess nginx is wiser, since it supports a higher concurrency level. Right?</p>
  
  <p>I have also come across this <a href="https://stackoverflow.com/a/2902718/553801">clever analogy</a>, but I am not sure if it could be applied to my situation. The analogy also seems to be very <em>idealist</em>. I have rarely seen my computer run at 100% CPU (even with a umptillion Chrome tabs open, Photoshop and what-not running simultaneously)</p>
  
  <p>Also, I have come across a SO post (somehow it vanished from my history) where a user asked how many threads they should use, and one of the answers was that it's perfectly acceptable to have around 700, even up to 10,000 threads. This question was related to JVM, though.</p>
  
  <p>So, let's estimate a fictional user-base of around 5,000 users. Which approach should would be the "most concurrent" one?</p>
  
  <ol>
  <li>A reactor pattern running everything in a single thread.</li>
  <li>A reactor pattern with a thread-pool (approximately, how big do you suggest the thread pool should be?</li>
  <li>Creating a thread per connection and then destroying the thread the connection closes.</li>
  </ol>
  
  <p>I admit option 2 sounds like the best solution to me, but I am very green in all of this, so I might be a bit naive and missing some obvious flaw. Also, it sounds like it could be fairly difficult to implement.</p>
  
  <p>PS: I am considering using <a href="http://pocoproject.org/" rel="nofollow noreferrer">POCO C++ Libraries</a>. Suggesting any alternative libraries (like <a href="http://www.boost.org/" rel="nofollow noreferrer">boost</a>) is fine with me. However, many say POCO's library is very clean and easy to understand. So, I would preferably use that one, so I can learn about the <em>how</em>s of what I'm using.</p>