Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
This repository was archived by the owner on Jul 16, 2021. It is now read-only.

Queue Multi-Task Handling #2460

@aarreedd

Description

@aarreedd

Laravel "Job Batching" allows you to dispatch multiple tasks at once. But I want to do the opposite: Have one handler receive multiple tasks at once.

For example, the ProcessPodcast class from the docs could be called ProcessPodcasts and the constructor would receive an array of Podcast classes instead of just one.

Configuration

There are two main configurations: "group size" and "wait time".

Group Size would be the maximum number of Podcast classes the ProcessPodcasts class can receive at once.

Wait Time is how long a job will wait for a full group of jobs. After some period of time (e.g. one minute) if there are still fewer than a full group of jobs, the queue will just send all waiting jobs to the handler.

Why would you want this?

When processing a job has significant setup overhead it may be more efficient to process multiple jobs at once.

Adding more queue workers does not solve this problem. Multiple works could allow you to process the jobs more quickly, but not more efficiently.

Example

Imagine that the ProcessPodcast job launches an EC2 instance to process each podcast. That setup takes a lot of time. It would be more efficient for the ProcessPodcasts class to receive a group of Podcasts so it can use the same container to process all of them.

Implementation in AWS Lambda

This feature already exists in AWS when using SQS and Lambda. You can configure each SQS message to trigger a Lambda function. Or you can configure a "batch size" and when your Lambda function is invoked it will receive an array of SQS messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions