Hi everyone, my name is Gabby Moreno Cesar and I'm with the IBM Cloud team.
In this video we'll show you how to run batch jobs with IBM Cloud Code Engine. Batch jobs
are pieces of code meant to perform specific tasks at certain times of day and then stop -
for example, processing daily records in a back-end system.
So, starting at the Code Engine "overview" page, we are going to choose the "Run your
container image" option and give it the name of a "batch" container image: "hmo-task"
To save time, this image has already been built for us.
Let's go ahead and hit "Start creating" to move on to the next step.
On this screen we can enter many different configuration options but for now let's just
stick with the defaults for everything except for the first one... for that we're going
to choose "Job" instead of "Application". With that let's go ahead and hit "Create"
We have now created the definition of our Batch Job. Meaning, we didn't actually run it yet - we
just made the platform aware of our Job. This will allow us to run it over and over as needed.
Before we actually run the job, let's first talk about what the job will do.
For this demo we have an application that manages a set of customer records and our Job will process
all of the customer records in our backend system. You don't need to
understand what the records are for, or what this front-end application is that I'm showing.
The key things here are the two numbers that are from our backend system. The first shows
the number of records in there, and the second shows how many have been processed. As the batch
job runs, the second number will increase and eventually should equal the first number.
Let's just keep this off to the side so we can watch it.
Let's now run the batch job by hitting the "Submit job" button.
You'll notice there are a few options that we can modify.
First, and foremost, is the 'Array indices' field.
This tells Code Engine how many instances of the job to execute. It's showing a default value of
"1" - but this demo we're going to run 10 of them so we're going to enter "1-10"
Code Engine allows for you to not only specify how many instances to run,
but how those instances are numbered. Meaning, are they numbered 1, 2, 3... or should they be
numbered 1,3,5,7, ... if we only want odd numbered instances? Often the instance number is used a
part of the processing to ensure each instance's work doesn't overlap with any other's.
We're going to leave the rest of the configuration options alone and just press "Submit job".
Notice in the window that we have 10 pending instances.
Each instance will eventually move from "pending", to "running" and finally "completed" states
Notice in the application window you can see the number of records processed is going up... fast.
And in a matter of seconds all 10 jobs are completed
Let's quickly summarize what happen though. With just the name of a container image we defined
a Job and then executed it with 10 instances. We didn't have to do any other infrastructure
setup or management. As a developer of this code, all I had to worry about is the business logic of
workload - nothing else. And that's the goal of Code
Engine - allowing developers to focus on what's important... coding.
That's all the time we have today, but hopefully you found this quick walk-thru of how to manage
batch jobs in Code Engine exciting and I encourage you to look at our other videos to see more key
Code Engine features. And, of course, we hope that you'll go to www.ibm.com/cloud/code-engine to play
with it yourself. Thank you.