Posts Tagged #queues
Every article on the Techalyst blog tagged with #queues.
Handling API Rate Limits in Queued Jobs
If your jobs call a third party API, sooner or later you will hit its rate limit and start getting 429 Too Many Requests. Hammering the API ha...
Stop Hammering a Dead API From Your Queue
Your CRM integration goes down at nine in the morning. There are two thousand contact-sync jobs on the queue, and every one of them is now goi...
Laravel Queue Configuration Keys Explained
A few queue settings trip up nearly everyone, mostly because two of them look like they do the same thing and actually do not. Here is each on...
How to Retry Failed Jobs in Laravel
A third-party endpoint was down for twenty minutes overnight. It is back, and now there are four hundred rows sitting in failed_jobs. The work...
Getting Notified When a Laravel Job Fails
A job that creates shipping labels retries three times against a carrier API that is having a bad morning, then gives up. The row lands in fai...
Job Has Been Attempted Too Many Times or Run Too Long
You open your logs or failed_jobs table and find a job marked failed with MaxAttemptsExceededException and the message "Job has been atte...
Making Queued Jobs Safe to Run Twice
A customer gets charged twice. Or the same shipping confirmation lands in their inbox three times. You read the job, and the logic is fine. It...
Handing a File Upload to a Queued Job
A support ticket lets people attach a screenshot, and you want the resizing done in the background. The obvious thing fails immediately: There...
The Database Queue Driver Is Production Ready
For years the advice was clear: never run the database queue driver in production, use Redis. That advice is out of date. Modern databases fix...
"Serialization of 'Closure' Is Not Allowed" in Laravel
This one fails immediately, in the request, before the job is ever queued: Others in the same family show up as Serialization of 'PDO' is not...
Ensuring Horizon Terminates Gracefully
One of Horizon's nicest features is graceful shutdown: when told to stop, it waits for any in-flight jobs to finish before terminating its wor...
ModelNotFoundException in Queued Jobs
A job blows up in failed_jobs with a message like this: Listing 41 definitely existed when you dispatched the job. It does not exist now. Noth...
How Laravel Prepares a Job for the Queue
When you dispatch a job, it does not run there and then. It gets turned into a small record and stored, in MySQL, Redis, or SQS, until a worke...
Dispatching Unique Jobs to Laravel Queues
Here is a common need. Every time a product is updated you dispatch a job to rebuild the search index. If ten products are edited in a minute,...
When Queueing a Job Makes Things Worse
Once you have a queue running, everything starts to look like a job. Slow endpoint? Queue it. Sending an email? Queue it. Updating a counter?...
Database Transactions in Laravel, and the afterCommit Trap
A database transaction groups several queries into one all or nothing unit. Either every query succeeds and the changes stick, or one of them...
Prevent Your Queued Jobs From Running Twice
You notice the same job ran twice. The email went out twice, the charge happened twice, and you are sure you dispatched it once. Before suspec...
Your Jobs Are Running Instantly Instead of Queuing
You moved a slow thumbnail job onto the queue, deployed, and the endpoint is exactly as slow as it was before. There are no rows in the jobs t...
Rationing Your Laravel Queue Workers' Memory and CPU
If your workers share a server with your web app, or run on a small box, they can quietly eat the resources your site needs. The goal is to le...
Why Your Queue Worker's Memory Keeps Climbing
People love to argue about whether PHP is suited to long running processes. In practice, Laravel workers crunch enormous numbers of jobs relia...