Azure Web Job - Performance impact of multiple functions in the same web job and/or multiple web jobs in the same web app?

前端 未结 2 1748
醉酒成梦
醉酒成梦 2020-12-11 17:18

There are 3 ways to deploy a new function via web job:

  1. Create a new web app, and deploy a web job with the function in it.
  2. Add a new function to an ex
相关标签:
2条回答
  • 2020-12-11 17:32

    This is a hard question to answer and I try'll to give you some clues. Here is few things that you should keep in mind:

    • performance: If you put every in the same job, the jobhost will create a new thread every time one of your functions is invoked. Having too many threads in the same process can hurts performance. My choice would be to limit the number of threads running in the same process. If you google "Multithreading vs. Multiprocessing", you'll find some great answers about this. Anyway there is no general guideline and you should use a profiling tool to help you deciding what is the best solution in your case.

    • Crash: Let's say you have 2 functions in the same job. If one function crashes, it may crash the whole job. So you may need to create separate jobs to isolate functions that need to be resilient and run all the time.

    • Configuration: Multiple jobs in the same web app can share configuration (App Settings). Depends on how you manage your configuration (from the portal or using app.config) you may need to create separate web app for jobs that do not have the same configuration.

    • Deployment: When you deploy a webjob inside a webapp, it will cause the webapp to restart. If you have a web site or another job that have to keep running, you may need to create a separate web app so that new deployment of a particular component does not impact the availability of the other components.

    • "Scaling": Webjobs will run on all the instances of you app service. You can specify a particular job or a particular function to be a singleton. This is also something that you should keep in mind.

    Otherwise you may be interested in Azure Functions. It uses a dynamic app service plan that scales automatically and you only pay when you functions are running. Each function are independent so you don't have to worry at all :-)

    0 讨论(0)
  • 2020-12-11 17:49

    As I know, you could leverage WebJobs to execute custom jobs based on different types (scripts, executable programs, etc.) within the context of a web app. In order to minimize the impact of WebJobs on the performance of the web app, you could try to create an empty Azure Web App in the new App Service Plan to host your WebJobs which could do some long-running workflows, I/O-intensive jobs, CPU-intensive jobs, etc. I recommend that you could refer to best-practices-background-jobs. Also, there is a related thread about Azure Webjobs: One Job with several Functions, or several Jobs with 1 function each, you could refer to it.

    0 讨论(0)
提交回复
热议问题