What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Gearman lets a PHP application hand work to a job server, which dispatches it to a worker process that has registered the requested function. The worker can run separately from the PHP client—even on another machine—so a request can offload work instead of doing everything inline. For background submissions, the client can continue without waiting, but the simple PHP call does not return the job’s result.
How Gearman works
Gearman coordinates work; it does not execute your application logic itself. The client submits a named job and workload, the job server (commonly gearmand) finds an available worker registered for that function, and the worker runs the application code and returns a result when the submission mode expects one. The client, server, and worker are separate roles and may run in different processes or on different machines. Their APIs communicate with the job server over TCP. Client and worker code can use different languages if they agree on the function name and workload format. See the Gearman project overview.
- Client: creates and submits the job.
- Job server: routes submitted work to a worker registered for the matching function.
- Worker: performs the function and, when applicable, returns its result.
How to use Gearman in PHP
The basic exchange uses GearmanClient in the submitting application and GearmanWorker in a separate worker process. The client and worker must connect to a reachable Gearman server and use the same function name. They must also agree on how the workload is represented—for example, plain text, JSON, or another agreed format.
1. Install compatible components
Install a Gearman server and its required libraries, then install and enable the PHP extension. The PHP manual lists libgearman, libevent, uuid, and a running Gearman server among the requirements: PHP Gearman requirements. The extension repository describes the extension as a wrapper around libgearman and documents a build flow using phpize, ./configure, make, and make install, followed by enabling gearman.so: PHP Gearman extension repository. Follow instructions for the specific operating system, package source, PHP version, and extension release you deploy.
#1 Best Overall
2. Start the server and verify the extension
Start gearmand using the service or process setup for your system. Verify that the PHP runtime used by both applications has the extension loaded; a web server’s PHP configuration may differ from the command-line PHP configuration used to run a worker.
3. Register a worker function
Run a long-lived PHP process that connects to the server, registers a function name, and repeatedly calls work(). In the official PHP example, the worker reads the submitted content with $job->workload() and returns the reversed string using strrev(). Gearman handles dispatch and transport; the callback is your application code.
Rank #2
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction('reverse', function ($job) {
return strrev($job->workload());
});
while ($worker->work()) {
// Continue accepting work.
}
This is an introductory shape, not complete production error handling or process supervision. Keep the worker running under an appropriate service manager and add logging and recovery behavior for your environment.
4. Submit a job from a client
Create a client, connect it to the server, then submit the function name and workload. A result-returning call waits for the worker response:
<?php
$client = new GearmanClient();
$client->addServer();
$result = $client->doNormal('reverse', 'Gearman');
For this example, the worker must have registered reverse, and both sides must interpret the workload as the same string. The PHP manual documents the client and worker APIs and examples: PHP Gearman examples.
Choose foreground or background submission
Choose based on whether the submitting code needs a result before it continues—not simply on whether a task is “heavy.” A synchronous, result-returning call such as doNormal() waits for the worker’s response. The manual’s doBackground() example submits asynchronously: the client may exit without waiting, and it does not receive the result.
Rank #4
| Submission choice | What the caller gets | Use it when | Design question |
|---|---|---|---|
Result-returning call such as doNormal() |
The worker’s response after the call waits for completion. | The current code needs the result before proceeding. | Can the request tolerate waiting for worker execution? |
Background call such as doBackground() |
Submission proceeds without waiting for the worker result; the simple example does not return that result. | The caller can continue without the result immediately. | How will the application learn about completion or failure if that matters? |
The documented background example demonstrates submission, not a complete monitoring, retry, or failure-handling design. If the application must know whether a job completed, decide how to track and communicate that outcome rather than treating successful submission as successful execution. The manual also separates server options, logs, persistent queues, and troubleshooting into operational topics: PHP Gearman examples and related manual sections.
Where to run workers
A worker can run beside the client or on a separate machine. Keeping it local may be simpler for a small deployment; moving CPU-intensive or otherwise unsuitable work to separate worker machines can isolate that work from the user-facing process and lets an operator add workers. That flexibility adds operational responsibilities: the server and worker pool must be reachable, running, and monitored. The project describes Gearman as a framework for farming work out to other machines or processes better suited to do it: Gearman project repository. The cited project material does not establish a current performance benchmark or capacity guarantee, so size a deployment from its own workload and measurements.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchCompatibility, persistence, and security checks
Confirm PHP and library compatibility
The extension repository’s compatibility table lists extension 2.1.* with libgearman 1.1.18 or later and PHP 7.2–8.6. This is repository-stated compatibility, not a guarantee that every distribution, package build, or future release will work identically. Check the exact extension tag and the PHP and library versions in the target environment before installation: PHP Gearman extension repository.
Do not assume queued jobs survive a restart
The Gearman FAQ says jobs can wait for workers to register. It says survival across a job-server restart depends on compiling Gearman with a persistent-queue module, and names MySQL, PostgreSQL, SQLite, and memcached modules. These statements come from the project FAQ, whose guidance is legacy; they are not proof of persistence behavior for a current build. Verify the selected release and queue configuration before relying on jobs surviving a restart: Gearman FAQ.
Secure the server within the intended network boundary
The same FAQ says authentication was not then available and advises restricting network access or the listen address. Because this is legacy guidance, check current release documentation rather than assuming the same security features or limitations apply. Regardless, do not expose the service beyond its intended network boundary without confirming the controls available in the deployed version.
What to add before production
The introductory PHP snippets show the core API exchange, not a full production system. Before relying on a worker pool, decide how the application will respond to submission errors, how worker processes will be supervised, how job completion or failure will be observed when needed, and what should happen to queued work during service restarts. The Gearman manual notes that it is in progress and some sections are incomplete, so confirm version-sensitive deployment details against the exact release and your environment: Gearman manual.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

