ZendHQ JobQueue

The ZendPHP PHP extension includes a JobQueue to schedule jobs, defer jobs, and to run recurring processes in PHP applications. ZendHQ can schedule jobs for both PHP and non-PHP workers, and it can use either the command line interface or HTTP calls.

Consider the following scenarios:

Your application is processing images, aggregating data, performing complex data queries or transactions, generating reports, or similar, while the user is waiting.
You want to defer such long-running processes to be able to return a response to the user now.
During business hours, you need all computational power to handle your customer traffic.
You want to schedule all report generation to run only during low-traffic hours.
Your application needs to fetch an hourly news feed; you need daily or weekly or monthly reports; or you need to send daily announcements.
You want to schedule these jobs to be done automatically on a recurring schedule.

 

What is a job?

In heterogeneous environments, you may want to delegate work to other language runtimes or computational units. A job is a task to perform, either a CLI command or an HTTP call. You can give a job a scheduled time or run it on a recurring schedule.

You assign each job a priority; if a queue contains multiple jobs, the jobs with the highest priority are executed first. Delayed jobs with an overdue schedule are bumped in priority.

What is a queue?

You create named queues that group jobs and process them together. You assign each queue a priority. If there are multiple queues, the jobs in the queue with the highest priority run first. In each queue, you can define defaults for job priority, timeout threshold, number of retries, and when to keep job output. Queues enable you to scale.

Architecture overview

To process queues and jobs, the PHP API for JobQueue communicates with the ZendHQ node.

Supported Features

Feature PHP API
(programmatic)
ZendHQ User Interface
(manual)
JSON-RPC API
(programmatic)
Create and delete queues
Suspend and resume queues
List queues
Schedule and query jobs
Cancel jobs
Create and view jobs
See scheduled jobs and job details
View job history
Create monitoring rules for job failures and errors

Limitations

  • In the current release, CLI jobs run only on the ZendHQ node itself.

  • HTTP jobs support only GET, POST, and PUT calls.

  • HTTP jobs must return a 200-299 range status code to be considered successful. 300-399 status codes from HTTP workers are not interpreted as successes.