30.07.2012 Views

Reference Guide

Reference Guide

Reference Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Zend Server <strong>Reference</strong> Manual<br />

Jobs<br />

Creating a Job<br />

The Zend Server Job Queue component provides the ability to off-load script execution using Jobs. A Job<br />

is in essence a command to execute a PHP script according to the specific parameters you give it. The<br />

Job Queue component manages the timing and execution of jobs in the system.<br />

Jobs can be created to facilitate a wide range of situations that require you to asynchronously run PHP<br />

code. Here are a few examples:<br />

132<br />

Action Based Jobs for backend activities which are not a part of the HTTP request-response<br />

interaction with end users and need to be executed asynchronously.<br />

Scheduled Jobs that are set to execute according to a predefined schedule.<br />

One-time jobs that need to be run for any reason.<br />

Improving website performance by offloading processes to a different server.<br />

Optimizing long script execution by deferring running scripts to low peak times.<br />

Unifying script usage by referring to a job script outside the application code instead of repeating<br />

the same code for the same functionality. This also provides the added advantage of being able<br />

to implement changes throughout the application be editing a single script (instead of editing each<br />

individual instance of the script throughout the application's code).<br />

Working with The Job Queue API<br />

The Job Queue API is a set of functions that allow you to create, define and manage the execution of<br />

PHP code using a job.<br />

There are three types of Jobs you can create with the Job Queue API<br />

Queued Jobs - triggered as a direct result of an end-user activity<br />

Recurring Jobs - usually defined by the system's programmer. They are usually related to the<br />

system's maintenance and are not triggered by an action made by an end-user. The most<br />

common existing system to handle such jobs is cron which is usually a part of the operating<br />

system on most UNIX-like systems.<br />

One-Time Deferred Tasks (jobs) - usually a result of an end-user interaction, and may be<br />

deferred in order to optimize the system's load (e.g. cleanup or report generation tasks may be<br />

pushed to off-hours) but may also be a part of the application's business logic.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!