Reputation:
I've got some code that I'm considering putting into an Azure function and I've got a question/concern around the memory limitations and how the functions scale.
At the high end, the app could use about 800 mb of memory for a single execution, so if the max memory I can use is 1536mb, I can only have 1 concurrent execution without it running out of memory.
My understanding is that there can be a maximum of 10 instances, with x concurrent executions, but if the max capacity only allows me 1 running execution without it timing out, does that mean that I'd need to manually set the maximum concurrent executions to 1, and it would auto scale to a max of 10 instances, meaning I can only ever have 10 overall executions at a time?
If so, that is kind of a bummer, as I'd expect most executions to require far less memory than this.
It's a file manipulation function, so I can have a reasonably accurate guess about how much memory would be used based on the input file size, so if I restructure the back end to populate a variety of queues based on input size, I can have 1 queue for the high end stuff (with only 1 execution allowed at a time per instance), then divide it up into queues of other sizes and manually adjust the maximum concurrent instances, with a specific function targeting it's associated queue.
e.g. 1 queue for any file less than 1mb, as many executions as possible = 1 unrestricted function.
1 queue for 1mb-10mb input files, limited to 20 concurrent executions.
etc
It feels like more work than it should be, but it's not too much of a pain.
Does this seem like a sensible approach, or is there an easier way?
How exactly do you restrict the number of concurrent executions?
Upvotes: 1
Views: 2695
Reputation: 2802
A couple of background explanations:
queues
-> batchSize
in host.json for that app. Because you may run into memory restrictions, this may be your best bet anyway as you wouldn't have multiple functions running in parallel on the same host.I don't believe we publish the maximum available instance count anywhere, but I can tell you that 10 is not a limit anymore. That was an early limit that has since been lifted. Your best bet is to give it a try and see how you scale. If you add Application Insights support, you can pretty easily see the number of instances currently running in the Live Stream.
Upvotes: 0