title: WCF Concurrent Connections and Azure Service Bus Relay
body: <p>I have a WCF service listening to the Azure Service Bus Relay which for reasons I cannot change I am self hosting in a Windows Service.</p>
  
  <p>Once the service is put under concurrent load - typically by giving it a series of long running requests - we start to receive the following messages back from the Azure Service Bus:</p>
  
  <pre><code>&lt;Error&gt;
  &lt;Code&gt;502&lt;/Code&gt;
  &lt;Detail&gt;Bad Gateway.TrackingId:f0e32d08-2721-464c-a108-fe63f1efc443_G23,TimeStamp:4/23/2013 8:22:18 AM&lt;/Detail&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p>We suspect concurrent load causes this problem.</p>
  
  <p>My service is completely stateless.</p>
  
  <pre><code>ServiceHost = a WebServiceHost which we instantiate ourselves.
  Binding = BasicHttpRelayBinding
  InstanceContextMode = Single
  ConcurrencyMode = Multiple
  SessionMode = NotAllowed
  ServiceThrottlingBehaviour.MaxConcurrentConnections = A very large number
  Transport = Streaming
  </code></pre>
  
  <p>I have four questions:</p>
  
  <ol>
  <li>Does the above error seem like a concurrent load issue?</li>
  <li>What other configuration options should I be looking at to offer greater scale.</li>
  <li>In a self hosted Window Service environment what happens when the concurrent connections limit are hit? Will the service just fail? Will connections be queued?</li>
  <li>Is there a way that I can reliably monitor the number of concurrent connections at any given moment.</li>
  </ol>