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.
How much performance should I expect from functions? Is throughput on the order of thousands per second out of the question?
edit: I am regularly seeing this error in the logs:
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.
Looks like functions don't play well with service bus at scale?
edit 2 for solution Replacing this binding:
public static async Task Run(BrokeredMessage msgin, Binder binder, TraceWriter log)
{
var collector = await binder.BindAsync<IAsyncCollector<BrokeredMessage>>(
new ServiceBusAttribute("my-queue"));
...
}
with this:
public static IAsyncCollector<BrokeredMessage> collector;
public static async Task Run(BrokeredMessage msgin, Binder binder, TraceWriter log)
{
collector = collector ?? await binder.BindAsync<IAsyncCollector<BrokeredMessage>>(
new ServiceBusAttribute("my-queue"));
...
}
prevented socket exhaustion and the function was able to keep pace with the producer no problem.
Maximum instances: A single function app only scales out to a maximum of 200 instances. A single instance may process more than one message or request at a time though, so there isn't a set limit on number of concurrent executions. You can specify a lower maximum to throttle scale as required.
If you need to pass larger messages between functions, an Azure Service Bus queue could be used to support message sizes up to 256 KB in the Standard tier, and up to 100 MB in the Premium tier.
Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request.
Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.
I had the same issue in my Azure Function. The root cause was that I was exhausting all ports because I was creating a TCP connection inside Run method.
So when there were many parallel executions on the same machine, they all created connection, eventually exhausting all ports.
In that situation, connection was created as part of creation of ServiceBus client, and moving it to static variable resolved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With