title: Putting a Load on Node
body: <p>We have a C# Web API server and a Node Express server. We make hundreds of requests from the C# server to a route on the Node server. The route on the Node server does intensive work and often doesn't return for 6-8 seconds.</p>
  
  <p>Making hundreds of these requests simultaneously seems to cause the Node server to fail. Errors in the Node server output include either <code>socket hang up</code> or <code>ECONNRESET</code>. The error from the C# side says</p>
  
  <blockquote>
    <p>No connection could be made because the target machine actively refused it.</p>
  </blockquote>
  
  <p>This error occurs after processing an unpredictable number of the requests, which leads me to think it is simply overloading the server. Using a <code>Thread.Sleep(500)</code> on the C# side allows us to get through more requests, and fiddling with the wait there leads to more or less success, but thread sleeping is rarely if ever the right answer, and I think this case is no exception.</p>
  
  <p>Are we simply putting too much stress on the Node server? Can this only be solved with Load Balancing or some form of clustering? If there is an another alternative, what might it look like?</p>
  
  <p>One path I'm starting to explore is the <a href="https://github.com/lloyd/node-toobusy" rel="nofollow"><code>node-toobusy</code></a> module. If I return a 503 though, what should be the process in the following code? Should I <code>Thread.Sleep</code> and then re-submit the request?</p>