Limit number of instances of an azure webjob when scaling out

*爱你&永不变心* 提交于 2020-01-02 10:07:20

问题


I would like to limit the number of instances of a particular webjob when our app service plan scales out.

Whilst I am aware of the possibility of having a singleton instance I cannot find any docs to help if we want to limit the number of instances to n where n is a number greater than 1 but less than the total number of instances in the app service plan. For example our app service plan could scale out to be running 4 instances but only a maximum of 2 of them would be allowed to be running a given webjob.

I am (of course) aware that we could just have 2 app service plans with different scaling rules but I'd really just like to handle this within the existing plan if possible.

Background:

We have webapps and webjobs running in an app service plan set to auto-scale out as CPU usage increases above a certain threshold.

Our webjobs do 'background' processing tasks that are not particularly time sensitive but can be quite cpu intensive. If a lot of messages are in the queue these webjobs can consume almost all the available cpu resource and cause a massive scale-out. If we use a singleton webjob then the scale out only adds a single extra instance even at peak times and everything else still stays responsive. This would be fine execept the webjobs are taking too long to clear the queues. We'd really like to be able to balance this better to allow a couple of instances running the webjobs to allow slightly faster processing time but to avoid it adding the cpu-intensive webjob to the 3rd instance.


回答1:


Azure Web App supports per app scaling. But it is available only for Premium SKU App Service plans. Per app scaling scales an app independently from the App Service plan that hosts it. This way, an App Service plan can be scaled to 10 instances, but an app can be set to use only five.

For your issue, you could create a new web app to host your WebJob.

For how to use per app scaling, link below is for your reference.

High density hosting on Azure App Service



来源:https://stackoverflow.com/questions/45067648/limit-number-of-instances-of-an-azure-webjob-when-scaling-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!