Vapor now allows for individual queue concurrency settings, enabling developers to specify the number of concurrent workers for each queue separately.

Developers can configure their Laravel Vapor environment to utilize multiple queues for their application.

id: 12345
name: my-project
environments:
    production:
    queue-concurrency: 100
    queues:
        - default
        - invoices
        - mail
When deploying a configuration similar to the example above, Laravel Vapor creates three SQS queues (if they don't exist) and sets up an event mapping between each queue and a Lambda function to process the jobs. Although all queues use the same Lambda function to process jobs, which is generally efficient since Lambda picks up jobs almost instantly, this also means that all queues share the function's concurrency configuration. This configuration is either explicitly set using the queue-concurrency option in the vapor.yml file or uses the overall account concurrency by default. Previously, a busy queue consuming most of the allowed concurrency could cause other queues and even HTTP requests to be throttled by AWS. However, a recent update to Lambda and SQS has addressed this issue, allowing developers to set the concurrency of individual queues to prevent throttling.

id: 12345
name: my-project
environments:
    production:
    queue-concurrency: 100
    queues:
        - default: 80
        - invoices: 10
        - mail: 10
The above configuration sets the overall function concurrency of the queues to 100 and allocates the available concurrency among the three queues according to our desired distribution. What is happening behind the scenes? For the default queue, AWS sets a maximum concurrency of 80 during the provisioning process. If the queue processes enough jobs to reach the concurrency limit, the Lambda function stops reading from the queue until more capacity is available. This prevents throttling and avoids triggering the redrive policy, allowing SQS to avoid making decisions about throttled jobs. Laravel Vapor simplifies configuring individual queue concurrency. For instance, imagine a scenario where a video processing queue is likely to consume almost all of Lambda's maximum invocation time of 15 minutes. To prevent this queue from monopolizing resources, we can create a default queue with no concurrency limit, ensuring that jobs are processed quickly without hitting the concurrency limit. We can also create a videos queue with a concurrency limit of 2, which takes longer to process jobs but prevents the rest of the environment from being affected.

id: 12345
name: my-project
environments:
    production:
    queue-concurrency: 100
    queues:
        - default
        - video: 2
Deploying the configuration above will do just that. It's that simple! We at Vapor are committed to crafting the best serverless PHP experience, and we hope you agree this feature is another step in the right direction. We look forward to and welcome any feedback you may have.

Comments

Popular posts from this blog

Laravel Model

Laravel Artisan: The Command-Line Interface for Your Laravel Application

Laravel Facades