3

How are resources like CPU/Memory split between apps in app service plan. Is it an equal split between the apps ? Can any one app consume say 90% of the resources. I am asking this because if the resources allocated to apps in app service plan are dynamic i will create several slots (one for dev, staging, prod) This way i will be sure that dev,staging won't eat up more resources and prod app can take up say 99% of the app service's resources if needed

jayasurya_j
  • 1,519
  • 1
  • 15
  • 22

3 Answers3

2

They are not split, they are shared. You cannot control resource quotas for apps under App Service Plan, afaik. So it is possible any single app can take all the resources App Service Plan offers.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Are you sure that one of the apps can take up say 99% of the resources when needed? – jayasurya_j Sep 26 '19 at 14:37
  • I never said that. If said resources are available - it would be able to claim them. You cannot make one App to take resources from the other App if the App is using them. – 4c74356b41 Sep 26 '19 at 14:38
  • Of course, one app can't take resource when another app is using it. My doubt basically is will the resources be shared dynamically between the apps. can an app free up a resource if it's not using much and can an app take up more resources if needed and if its available – jayasurya_j Sep 26 '19 at 14:46
  • no, unless you code your app to free up resources. App Service Plan cannot force your app to release memory\tcp connections\whatever – 4c74356b41 Sep 26 '19 at 14:51
  • Let's take an example. Consider an app service plan with 1GB Ram and has 2 apps running in it. What can be the maximum memory each app can get? Is it capped at 500Mb for both? Or is this dynamic based on the app's usage – jayasurya_j Sep 26 '19 at 15:02
  • 3
    dynamic based on app usage – 4c74356b41 Sep 26 '19 at 15:10
1

It isn't possible to restrict the resource usage per app within a single node in an app service plan.

However, if you have multiple nodes, you can restrict how many nodes the app scales up to.

The details of which are documented here: https://learn.microsoft.com/en-us/azure/app-service/manage-scale-per-app

Here is an example if using ARM templates where the number of workers is restricted to 5.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters":{
        "appServicePlanName": { "type": "string" },
        "appName": { "type": "string" }
        },
    "resources": [
    {
        "comments": "App Service Plan with per site perSiteScaling = true",
        "type": "Microsoft.Web/serverFarms",
        "sku": {
            "name": "P1",
            "tier": "Premium",
            "size": "P1",
            "family": "P",
            "capacity": 10
            },
        "name": "[parameters('appServicePlanName')]",
        "apiVersion": "2015-08-01",
        "location": "West US",
        "properties": {
            "name": "[parameters('appServicePlanName')]",
            "perSiteScaling": true
        }
    },
    {
        "type": "Microsoft.Web/sites",
        "name": "[parameters('appName')]",
        "apiVersion": "2015-08-01-preview",
        "location": "West US",
        "dependsOn": [ "[resourceId('Microsoft.Web/serverFarms', parameters('appServicePlanName'))]" ],
        "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverFarms', parameters('appServicePlanName'))]" },
        "resources": [ {
                "comments": "",
                "type": "config",
                "name": "web",
                "apiVersion": "2015-08-01",
                "location": "West US",
                "dependsOn": [ "[resourceId('Microsoft.Web/Sites', parameters('appName'))]" ],
                "properties": { "numberOfWorkers": "5" }
            } ]
        }]
}

I do not believe you can set the worker node limit per slot, it is a per-app setting as far as I am aware (however I have not experimented).

Depending upon your performance targets v.s. the budget; I would suggest not sharing an app service plan between dev, staging and prod. Simply the act of compiling the code will slow down the app (depending on how high you have scaled the machine).

One suggestion is to have separate app service plans per environment and then use slots for zero-downtime deployment when moving towards production i.e. the slot swap feature.

Normally I'd presume on dev you will want to run experimental code and in staging you may wish to load test (or other tests), so you wouldn't want this to interfere with production traffic.

However, having said you will need to be careful to ensure that your dev and staging app service plans are not running unnecessarily. So you would need to manage deleting them when not in use. Therefore depending upon your performance / budget / development effort, it will inform you if you wish to share dev/stag/prod in one app service plan in the first place.

Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
0

If you applied the service plan to resource group then it is shared between all the resources within that group. Again, if we configure the specific resource with framework and CPU/Memory then depending upon the configuration CPU/memory is allocated.