World is now on Opti ID! Learn more


 -  DXP
Dec 19, 2017
  1930
(0 votes)

Scheduled jobs setup in DXC Service

Scheduled jobs is one of the essential features of Episerver platform. The main purpose of scheduled jobs is to execute in background repeatable long-running tasks within Episerver context, but outside of a web request. You can find more information about this feature here.

A long-running and resource-intensive scheduled job might negatively affect application performance when it runs on the same web server that also serves site visitors requests. There is a known solution for this - when the application is hosted on multiple web servers one of the web servers is dedicated to scheduled jobs by applying a configuration change (see Multi-sever scenario in the scheduled jobs documentation) and exclude the server from the load balancers list. This setup works fine for the hosting scenarios when the site administrator has full access to the web servers. However, in case of multi-tenant hosting solution like Azure App Service, there is no way to control configuration for individual web server instances. Here is how we solve this in DXC Service.

Since each web server instance in Azure App Service has identical application codebase and configuration, there is no way to configure the enableScheduler attribute for a particular instance. Instead, we configure enableScheduler=”false” for the whole WebApp that serves site visitor requests, and create a separate WebApp dedicated to scheduled jobs, that has the same codebase and configuration as the primary one, except enableScheduler is set to ”true.” To avoid any performance impact on the primary WebApp, the scheduled jobs WebApp is hosted on a separate App Service. Each App Service in Azure is essentially a set of web workers that can host one or multiple web applications (more in-depth information about this topic is available here). By using a separate App Service, we can ensure that scheduled jobs will run on dedicated web workers. The scheduled jobs WebApp and App Service is provisioned as needed in DXC Service and updated automatically by DXC deployment flow together with the primary WebApp, so this process is completely transparent for DXC customers and doesn’t require any code changes or configuration updates. The DXC deployment flow will also configure the enableScheduler attribute automatically. Note that dedicated scheduled jobs WebApp and App Service are created only on Pre-production and Production environments, but not on Integration.

Image scheduler-deploy.png

When developing a scheduled job for a site hosted in DXC-S, it is important to define the job as stoppable - set the IsStoppable property to true and implement the Stop method. This will give a chance for your job to perform a graceful shutdown when the web worker instance is recycled during jobs execution. Another important consideration, especially for the long-running jobs and jobs processing massive amounts of data, is to configure the job as Restartable. This will tell the scheduler service to start the job again if the job was shut down during the previous execution. It’s up to the jobs implementation to store some checkpoint to be able to resume the processing when restarted. 

Dec 19, 2017

Comments

Please login to comment.
Latest blogs
Make Global Assets Site- and Language-Aware at Indexing Time

I had a support case the other day with a question around search on global assets on a multisite. This is the result of that investigation. This co...

dada | Jun 26, 2025

The remote server returned an error: (400) Bad Request – when configuring Azure Storage for an older Optimizely CMS site

How to fix a strange issue that occurred when I moved editor-uploaded files for some old Optimizely CMS 11 solutions to Azure Storage.

Tomas Hensrud Gulla | Jun 26, 2025 |

Enable Opal AI for your Optimizely products

Learn how to enable Opal AI, and meet your infinite workforce.

Tomas Hensrud Gulla | Jun 25, 2025 |

Deploying to Optimizely Frontend Hosting: A Practical Guide

Optimizely Frontend Hosting is a cloud-based solution for deploying headless frontend applications - currently supporting only Next.js projects. It...

Szymon Uryga | Jun 25, 2025

World on Opti ID

We're excited to announce that world.optimizely.com is now integrated with Opti ID! What does this mean for you? New Users:  You can now log in wit...

Patrick Lam | Jun 22, 2025

Avoid Scandinavian Letters in File Names in Optimizely CMS

Discover how Scandinavian letters in file names can break media in Optimizely CMS—and learn a simple code fix to automatically sanitize uploads for...

Henning Sjørbotten | Jun 19, 2025 |