Multiple Azure Webjob instances on one queue

馋奶兔 提交于 2019-12-23 05:18:05

问题


I'm looking for a way to have multiple instances of my azure webjob running together and clearing my queue.

One of the functions of our application is to decrease the user's credit on every page view on their site (called by an ajax). We currently have close to 600 of these websites and every page view of their site is generating a call that results in a credit being deducted from their account (SQL Azure).

This happens real time in the and we are calling the sql server on ever one of these calls. So far it's working fine but I'd like to offload this task to the webjobs and a queue since I believe that is a better way of doing this.

My question is, how do I setup the webjob or a series of them to work with the same queue and work together to finish everything in the queue. Is there a way of spinning up more of them if lets say the queue reaches a high amount of massages?

I've searched everywhere this morning for this information but unfortunately I can't find anything on this.


回答1:


You can write a web job, using the Azure WebJobs SDK, that is triggered by the messages in your queue and then spin up multiple instances (by scaling). Each job instance will pick a different message from the queue.

You can use the Azure Websites scale feature. Each extra website instance means an extra webjobs instance too. http://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/

If you want to scale based on the number of queue messages, it think (not sure!) that you can use the management API to scale programmatically.



来源:https://stackoverflow.com/questions/24461772/multiple-azure-webjob-instances-on-one-queue

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