Last Saturday, I gave another series talk on “Serverless Architecture with Azure Functions” at Azure User Group held at Microsoft Singapore. In this post, I’ll cover some of the frequently asked questions on Serverless Architecture and Azure Functions.
Does Azure Function support the integration of multiple functions?
Yes. You can build and link multiple functions to do various tasks. Let’s take a look at this example below, an Asynchronous Background Processing example. In this Serverless Mobile Backend, we use TWO Azure Functions to complete two different tasks. First, the photo taken by the Mobile device will invoke a webhook trigger to Azure Functions which will store the images taken into Blob Storage — Output Binding. The second Function will take the images from the Blob Storage as Input, then processing the images to be scaled.
Which pricing tier should I go for?
Free Tier: As generous as Microsoft are, there is a free tier which offers up to 1 million executions per month for FREE to help get you started easily.
App Service / Dedicated tier: You pay based on the number of reserved VMs and you are responsible for the scale of your Functions. You are paying for an Always On instance, hence, you might want to fully use its resources as efficiently as possible.
Dynamic tier: You pay per number of executions. The platform is responsible for the scale, the platform auto scales on-demand. It is still of Best Practice to code your functions such that they run as efficiently as possible. In that way, Functions are scaled out only when it’s truly needed, and minimizing any cold start times for the new instances spinned up.
For consumption plan, there is currently a timeout after 5 minutes per execution.
Why is there a timeout period? How should I design my Azure Functions?
Essentially for Azure Functions, you are running off somebody else’s VM, which could be pulled down to be updated and so on. Hence, the best strategy is to design your Functions to not run for too long (for eg. 2 hours or more, etc.). Break up the Functions into many different steps using Queues to do Fan-out to break it up into smaller pieces. This boils down to its reliability, if one fails, the other Functions can catch up and retry again.
How much can Azure Functions scale?
According to the Product Team for Functions, Chris Anderson mentioned that, there were existing Microsoft Customers scaling more than a billion executions in a day without having to request for support. You can imagine how powerful Azure Functions is and can be. On top of that, Chris wrote a cool script to scale out quickly by creating an execution that exponentially increases the number of messages in a queue and scales down when it is not needed. So, there you go!
How do I convert my existing Web Service Application to Azure Functions?
You could start one block at a time from the back of the chain forward, this helps you to abstract whatever key APIs from the backend pieces to Azure Functions all the way up the chain. However, sometimes it might just make more sense to use a Web App, or with the existing architecture than a Serverless architecture. Azure Functions work well with existing infrastructure, so you could abstract and build certain services to Azure Functions, while the rest of the application could remain as it is.
Mitigation of cold start times on Azure Function?
Cold start is mainly composed of 3 different parts.
- When is the VM available?
- When does Azure have it hosted on the VM up and running?
- When does Azure go ahead to instantiate the code?
As for Azure Functions, there have been good progress in making the VMs as warm as possible by ensuring the load time to be as small as possible. Furthermore, Azure Functions leverage on pre-compiled assemblies so we don’t have to compile each time a Function comes up.
I hope these questions and answers help solve some of the doubts and implementations you might have with Azure Functions.
Here are the webcast & slides:
Credits: Engineers.sg for covering the event.