 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Lorna Mitchell: PHP and Gearman Unable to connect after upgrade
by Chris Cornutt February 28, 2013 @ 12:55:48
Lorna Mitchell has shared some advice about correcting an issue with PHP and Gearman after she did an upgrade via PECL.
I upgraded PHP and related pecl modules on my development machine today, and ran into a problem with Gearman. Actually I ran into more than one! Firstly the challenge of getting the newest pecl version working with a gearman version. Then an error where my existing PHP application couldn't connect to gearman after upgrade.
Running on Ubuntu, she found this tutorial helpful in getting Gearman back into a working state and installed (version 1.1.1). The "unable to connect" error turned out to be a change in how the Gearman connection needed to be made - the addition of a port to the connection string made things work again.
voice your opinion now!
gearman connection issue pecl ubuntu port
Vance Lucas: Handling Exceptions in Gearman Tasks (Even Background Ones)
by Chris Cornutt August 03, 2012 @ 08:28:25
Vance Lucas has a quick new post to his site showing you how to handle exceptions in Gearman tasks so that they can be logged correctly as a failure.
I recently had some issues with Gearman tasks throwing exceptions and killing the whole Gearman daemon. This made it nearly impossible to trace errors back to their origin, because the logged exception stack trace didn't provide much useful information, because it just logged where it failed in Gearman. [...] The only other place to add code that will catch exceptions for all jobs run is in the GearmanWorker::addFunction method.
To solve the issue, he ends up passing in a closure that takes in the $task and wraps its execution in a try/catch to handle the exception correctly. This is then thrown to a custom exception handler and logged for future diagnosis.
voice your opinion now!
gearman exception handling try catch closure
Ralph Schindler's Blog: Compiling Gearman (or anything) for Zend Server CE on Snow Leopard
by Chris Cornutt January 09, 2012 @ 10:59:35
Ralph Schindler has a new post to his blog today detailing the process you'll need to compile Gearman (or just about anything) on a Zend Server CE install on Snow Leopard.
Zend Server CE for Mac (as of this writing), comes compiled as an i386 executable only. This includes the PHP binary, php library, and apache binaries that come shipped with ZSCE. While ZSCE works great out the box with all the provided extensions, you might find that you want some additional 3rd party PHP extensions compiled/linked into this stack. That's where things get a little confusing, and in this post, we'll look at how to install the gearman extension.
He give two methods - the easy way where you can export a CFLAGS setting to compile with multiple architectures or the harder way (that works for Gearman), building static libraries. The full list of commands (and some example output) is included in the post. In the comments there's also an example of the install if you're using Macports.
voice your opinion now!
gearman compile zendserverce snowleopard osx mac tutorial
Matthew Wells' Blog: Kohana and Gearman - Practical Multitasking
by Chris Cornutt August 30, 2011 @ 11:39:11
Matthew Wells has a new post that looks at combining Kohana and Gearman to create a system to handle large data processing without slowing down the rest of the application.
A commonly identified bottleneck arises when dealing with large, 'expensive' data. This is commonly seen when an application posts a large volume of well structured data to the API (that some process must be carried out upon), before some form of structured receipt is then returned as a request response. [...] Analysing such a request tends to show high PHP CPU usage with lower database consumption. [...] The structured nature of data exchanged via an API means that we can, relatively simply and reliably, divide the submitted data and process it simultaneously with the help of a great tool called Gearman.
He walks you through the entire process including his initial thoughts on what the system should be and how it should behave when the requests are made. He shares the code he used to implement the system - a simple worker that processes part of the request and returns the results. The command-line calls to run the worker manually for testing are also included.
voice your opinion now!
multitask gearman kohana worker process api request
Gonzalo Ayuso's Blog: Watermarks in our images with PHP and Gearman
by Chris Cornutt March 07, 2011 @ 12:12:17
Gonzalo Ayuso had previously shown how to dynamically add watermarks to your images with the help of a mod_rewrite rule. One of the side effects of this is that, with a high load on your server, things can get bogged down quite quickly. His alternative? Add the watermarks to your images with Gearman workers.
In this second solution I will use a gearman worker to generate the watermarks. The benefits of gearman is the possibility of use a pool of workers. We can add/remove workers if our application scales. Those workers can be placed even at different hosts, and we can swap easily from one configuration to another.
He includes some sample scripts to illustrate the process - a Gearman client that'll call the watermarking process and a worker that takes in the image and transforms it with GD to add a new layer for the watermark.
voice your opinion now!
watermark image tutorial gearman worker client
Lorna Mitchell's Blog: Dealing with MySQL Gone Away in Zend Framework
by Chris Cornutt March 01, 2011 @ 10:03:01
Lorna Mitchell has a (very) quick tip for those using the Zend Framework with a MySQL database. Sometimes the inevitable "MySQL server has gone away" error will pop up - her tip shows you how to deal with it correctly in a long-running application.
The [Gearman] worker is a Zend Framework application, run from the CLI, and it seemed like the Zend_Db_Adapter had no way of knowing when MySQL had let go of its end of the connection. I tried a few different things, including Zend_Db_Adapter::getConnection(), but without success - until I dug through the source code (with some help from a friend) and realised that ZF was not reconnecting at all if it thought it already had a connection.
She ended up putting a connection into a registry and, when the process was done, forcing the connection to close. This made the next worker in the queue forcefully open another new connection rather than having the same one pending for (possibly) days at a time.
voice your opinion now!
mysql goneaway error zendframework gearman
Lorna Mitchell's Blog: Using Gearman from PHP
by Chris Cornutt February 16, 2011 @ 09:51:07
Lorna Mitchell has a new post today about using a popular backend processing tool, Gearman, from inside of PHP. Her example gives a full overview of how to add a new job and write the worker for it to make things happen.
Basically, this application generates some PDFs from a variety of data sources, makes images, and emails it. Since the whole data processing, image handling, PDF generation process is fairly heavy, I'm putting the requests to generate these onto a gearman queue and having some workers process the jobs.
You'll need to have the Gearman server and extension installed (sample instructions here for Ubuntu) to use the sample code she gives using the Gearman_Client and GearmanWorker objects to create the pieces of the puzzle. You can find out more about the Gearman PECL extension here.
voice your opinion now!
gearman tutorial pecl extension worker jobs example
|
Community Events
Don't see your event here? Let us know!
|