“Serverless is a consequence of a focus on business value “ : Ben Kehoe - Cloud Robotics Research Scientist at @iRobot
Introduction
The goal is to design and program an arbitrator based on the broker pattern. This arbitrator will schedule jobs across machine pool on Azure. It is an API which can be invoked for job scheduling. Job priority and job processing commands are the parameters to be passed on to the API. Jobs have to be performed in sequential order based on the job priority. The machines can have different hardware specifications. The time taken for completion of the jobs might be different.
We have three different design options which we look at evaluating. Option 1 is the Azure Batch. Azure Batch executes the batch jobs and Batch API is provided to customize the batch execution. Option 2 is Azure Functions which is server-less and computing based. HTTP API is provided for execution of Azure functions and jobs. Option 3 is Azure Workflow based Logic apps where applications are dependent on workflow and jobs have a workflow which has rules.
Option 1 - Azure Batch
Azure Batch is used for executing parallel batch jobs on Azure. It initiates, creates and manages a compute nodes pool. The pool has virtual machines as nodes. The applications are installed and jobs are executed on the virtual machines. Batch API is provided to create a cluster or a scheduler for installing, managing and scaling the job execution. Azure portal is used for configuring, managing and job monitoring.
The portal has batch API and tools. Software-as-a-Service applications or client applications are built using batch for large scale job execution.
Executing a Monte Carlo risk simulation for a bank or trading company is an example of batch job execution. Image processing is another common use case. Batch has no additional charge. Resources which are consumed are metered for billing purposes. The resources which are consumed usually are virtual machines, storage, and networking.
Option 2 - Azure Functions
The serverless computing service model is possible on Azure. The Azure functions are used to execute code on demand on the cloud infrastructure. These functions are used to execute a script and code. Events are generated which are related to the function execution.
Azure application platform has features to implement code triggers. Events are triggered by the code from applications, services, and data modules. These functions help in managing data sources and messaging solutions. HTTP based API endpoints are used for applications on Azure functions. Azure functions consume resources on demand and they can scale.
Option 3 - Logic Apps
Applications which are based on workflow and integrated with different data sources can be developed using Azure Logic Apps. It has a visual designer for workflow configuration. Workflow can be configured using connectors and logic using the module level connectors for integration and data management.
Integration platform as a service is provided for scaling the applications for demand management. The service is based on the serverless computing model. Business logic is included in the application by the developers. These applications consume resources on demand and have a consumption-based pricing plan.
Arbitrator Design
After evaluating the three options, Azure functions is selected. Azure functions are scalable and perform very well for job execution. Jobs are configured in jobs.json. Sample JSON is included below.
- {"jobs": [
- {
- "id": "1",
- "name": "job1",
- "priority": "3"},
- {
- "id": "2",
- "name": "job2",
- "priority": “1" },
- {
- "id": "3",
- "name": "job3",
- "priority": “2" }
- ]
- }
Jobs are read by the broker. The broker passes the job information based on priority for execution by the Job scheduler. Job scheduler picks the name and selects the job to be executed. Broker and Job scheduler are Azure functions.
The URL for the broker - https://arbitrator.azurewebsites.net/api/Broker
To execute each job, you can use the URL below and pass on the command parameter as job1, job2 or job3.
https://arbitrator.azurewebsites.net/api/JobScheduler?code=gscDxBe31xRg90oOe6Ea7lUEw/pa9staabjPozKZqyyxBCGa1zabJg==&command=
The output expected for job1 will be 123. Job2 output will be 3456. Job3 output will be 7890.