title: Am I expecting too much scalability from azure functions?
body: <p>I have an azure function running on the consumption plan that gets triggered by a service bus topic then simply adds another message to a queue (so basically does no processing, just IO). The trigger topic is being filled at a rate of ~1000/second. I naively thought that the function could easily keep pace, but it is in fact hopelessly overwhelmed and the topic subscription fills very quickly. I have it running for hours so I suspect it is fully scaled out.</p>
  
  <p>How much performance should I expect from functions? Is throughput on the order of thousands per second out of the question?</p>
  
  <p><strong>edit:</strong> I am regularly seeing this error in the logs:</p>
  
  <blockquote>
    <p>The connection attempt lasted for a time span of 00:00:00. TCP error
    code 10013: An attempt was made to access a socket in a way forbidden
    by its access permissions. </p>
  </blockquote>
  
  <p>Looks like functions don't play well with service bus at scale?</p>
  
  <p><strong>edit 2 for solution</strong>
  Replacing this binding: </p>
  
  <pre><code>public static async Task Run(BrokeredMessage msgin, Binder binder, TraceWriter log)
  {
   var collector = await binder.BindAsync&lt;IAsyncCollector&lt;BrokeredMessage&gt;&gt;(
                  new ServiceBusAttribute("my-queue"));
  
  ...
  }
  </code></pre>
  
  <p>with this:</p>
  
  <pre><code>public static IAsyncCollector&lt;BrokeredMessage&gt; collector;
  public static async Task Run(BrokeredMessage msgin, Binder binder, TraceWriter log)
  {
       collector = collector ?? await binder.BindAsync&lt;IAsyncCollector&lt;BrokeredMessage&gt;&gt;(
                  new ServiceBusAttribute("my-queue"));
  
  
      ...
  }
  </code></pre>
  
  <p>prevented socket exhaustion and the function was able to keep pace with the producer no problem.</p>