Kubernetes scaled job helps us running one job per event/message we recive from the queue/even hub. We can have an event handler job which can handle more than one type of event messages or queue messages. Let's look at what we need to consider when we are defining more than one trigger, with kubernetes event drivern autoscaler (KEDA) for a scaled job.
The trigger definition can be as shown below.
When we more than one trigger, how we need to define a strategy to identify how many job instances should be created when events are recevied in one or in both event hubs.
For that in scaling strategy we can define multipleScalersCalculation parameter.
KEDA documentation here provides clear explanation on how the multipleScalersCalculation behaves.
If you implment your scaled job logic to only process one event per job, the ideal value for the multipleScalersCalculation would be sum. In addition to that setting the scaled job minReplicaCount as 0 is recommended due to, when no events there should not be any running jobs. See example below (note that pod template is removed for brevity).In scaled job implmentation, it would be useful to setup logic to wait for a new event, for a given timeout, say 60 seconds for example and make the job terminated after timeout. this is necessary due to KEDA may scale addtional jobs (mostly 1 addtional job when multiple events are received), beyond number of the events received in the event hubs or the queue. Any additional job should terminate if there is nothing to process within a given timeout period.
No comments:
Post a Comment