-
Print
-
DarkLight
Factors that affect cost
Choice of SKU
Logging levels
Scaling choices
Things to Think about
Choice of SKU
There are a number of choices of SKU for function apps ranging from:
consumption per execute cost models
Premium based on core seconds with a minimum of 1 node
App Service plans and ASE choices which provide a per hour billing model
AKS hosting
Container App hosting
You should consider which is the most appropriate plan for your function app based on expected usage.
There are also some feature differences between types of function app hosting.
Consumption | Flex Consumption | Elastic Premium | App Service | Container App | |
---|---|---|---|---|---|
Cost Model | Per execution | Per execution | Per second for vcores/memory | Per second | Per vcore second |
Free options | 1m executions per month | 250k executions | n/a | Free tiers | Free allowance |
Additional costs |
|
|
| ||
Reservations / Savings Plans | n/a | n/a | Yes | Yes | Partial |
Scale to Zero | Yes | Yes | No | No | Yes |
Common to the above options are additional costs like:
Storage
Logging
Consider all of your function apps when planning
When you start with your first function app the usage might lean towards a specific type of hosting but it may be the case that later you add other function apps which lean towards a different hosting model. The more you can think about things you might be likely to do in the short / medium term future then you can factor these into your hosting decision.
You can move things around to some degree later.
App to Plan mapping
It is common that you might have more than 1 function app hosting plan. Each instance of a function app which is running will have a footprint on the host. If you consider an example where you chose to use an App Service plan to host 20 function apps in .net then you would have the function app loaded and running the .net runtime in each process. It might be that some of the function apps process lots of requests, but others do very little work.
In this scenario, it might be a good idea to consider moving some of the function apps to a consumption plan where they are only using resources when needed, and then you leave more capacity on your app service plan.
Scale out vs Scale up
If you are using an app service plan, then you might need to consider the impact of scaling out vs scaling up on cost. If you are hosting Function Apps that are using a lot of capacity on the host by default when doing little work then they are more likely to need to scale out regularly.
You might find its better to scale up your plan so it stays at 1 node more often than leave it at a smaller plan where it is often scaling out to 3 nodes.
Elastic scaling
Elastic scaling is good for cost, this means you can scale out just when you need to and can dynamically scale back in when things are quieter. For burst load patterns then you might find this is a really good option to help with optimizing cost.
Dependencies
Function Apps will have dependencies on storage and app insights. When planning for cost optimization make sure to consider the impact of the function app usage on those resources so you do not have unexpected costs.
Common Optimizations
Logging Levels
In the function app host.json file you can configure the log levels if App Insights is being used for compatible function code. It is common that users will take default settings which might be too verbose for your needs resulting in a lot of additional log events which can mount up to a significant cost for data you may not be using.
Techniques like sampling can help here. You can also change logging settings easily or configure them to appropriate levels to begin with in the host.json
Read more: Tuning App Insights for Azure Functions
How can Turbo360 help to reduce Azure Function Apps cost?
Visualize Cost
In Turbo360 you can visualize the cost of your Function App resources within nodes on our tree view. This allows you to democratize cost management so you can create a scope to look at the costs for an application together, which may include a Function App and its associated storage and logs along with other resources it may use, such as a database. This makes it much easier to manage your overall costs for this application and set up monitoring.
Rightsizing
Turbo360 can help you with rightsizing recommendations. These can help you identify cases where an app service host might be over-sized and wasting money. Examples of rightsizing can include for App Service hosted functions.
Reservation Management
Turbo360 can help you identify cases where app services could benefit from a reservation which would reduce your costs
Scheduled Workload Optimization
Turbo360 can help you in scenarios where you could schedule the resizing of an app service plan based on schedules, such as downsizing at the end of the business day to reduce cost.
Useful Resources
The below video talks about the impact of defender on storage costs in Function App scenarios