title: Azure Functions - Scaling And Memory Limitations
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>If so, that is kind of a bummer, as I'd expect most executions to require far less memory than this.</p>
  
  <p>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.</p>
  
  <p>e.g. 1 queue for any file less than 1mb, as many executions as possible = 1 unrestricted function.<br>
  1 queue for 1mb-10mb input files, limited to 20 concurrent executions.
  etc</p>
  
  <p>It feels like more work than it should be, but it's not too much of a pain.</p>
  
  <p>Does this seem like a sensible approach, or is there an easier way?</p>
  
  <p>How exactly do you restrict the number of concurrent executions?</p>