News Feed
Jobs Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell:
Working with PHP and Beanstalkd
March 06, 2014 @ 10:36:53

Lorna Mitchell has posted a new tutorial to her site today walking you through using Beanstalkd with PHP for a simple queuing setup in your application. Beanstalkd is "a simple, fast work queue. Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously."

I have an API backend and a web frontend on this project (there may be apps later. It's a startup, there could be anything later). Both front and back ends are PHP Slim Framework applications, and there's a sort of JSON-RPC going on in between the two. The job queue will handle a few things we don't want to do in real time on the application, such as: updating counts of things like comments, [...] cleaning up, [...] other periodic things like updating incoming data/content feeds or talking to some of the 3rd party APIs we use like Mailchimp and Bit.ly.

She starts with a look at how to add jobs to the queue (she assumes that you've already set up the Beanstalkd instance at this point). She uses the Pheanstalk library for the job handling and includes a sample call to configure the connection and create an instance to make the connection. The sample job contains an array of data including an "action" and "data" for it to use when processing. She also includes an example of a basic PHP-based Beanstalkd worker that will go through currently pending jobs and execute them based on the action/data combination. In the sample worker script, she defines the action as a method in the class to be executed directly on the worker instance. She finishes off the post with a few "things to remember" about working with workers and long-running PHP scripts.

0 comments voice your opinion now!
beanstalkd tutorial introduction pheanstalk worker

Link: http://www.lornajane.net/posts/2014/working-with-php-and-beanstalkd

Wan Qi Chen:
Background jobs with php and resque (Series, Parts 4, 5 & 6)
October 17, 2012 @ 09:05:55

Wan Qi Chen has returned with the next three parts in his "Background jobs with PHP and resque" series (first parts here) with parts four, five and six helping you implement the concepts from the first three parts.

That sixth part of the series uses the CakeRisque plugin to make the integration simpler. Save that, you could integrate this setup pretty easily into whatever framework you choose.

0 comments voice your opinion now!
resque tutorial series implementation parts worker cakephp


Justin Carmony's Blog:
PHP Workers with Redis & Solo
January 11, 2012 @ 11:50:52

In this latest post to his blog Justin Carmony shares some of his experience using Redis and Solo to asynchronously run queries and return data without the user having to wait.

Sometimes there are situations when you want to parallel process things. Other times you might have a list of tasks to accomplish, and you don't want to make the user wait after pressing a button. This is where "Workers" can come in. They are independent scripts that run along side of your application, performing tasks, or "jobs."

Solo is a very basic Perl script that ensures only one process of a type is running at once. Using this and a PHP library called predis, he shows how to set up workers and add items to your processing queue. The workers themselves run on a cron job and connect to the queue server to see what they need to do. He also throws in some "bells and whistles" - extras that can enhance your worker system: queue monitoring, version numbering and killing workers based on a hash value.

His code examples are posted on his github account and a screencast is included in the post to show the system in action.

0 comments voice your opinion now!
redis solo cron tutorial queue worker


Matthew Wells' Blog:
Kohana and Gearman - Practical Multitasking
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.

0 comments voice your opinion now!
multitask gearman kohana worker process api request


Gonzalo Ayuso's Blog:
Watermarks in our images with PHP and Gearman
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.

0 comments voice your opinion now!
watermark image tutorial gearman worker client


Lorna Mitchell's Blog:
Using Gearman from PHP
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.

0 comments voice your opinion now!
gearman tutorial pecl extension worker jobs example


Ibuildings techPortal:
Doing the Heavy Lifting Gearman and Magento
January 17, 2011 @ 14:09:38

New from the Ibuildings techPortal today, there's a tutorial from Michael Davey looking at using Gearman with Magento to do some of the "heavy lifting" of queuing jobs from inside the tool.

With most web applications, there comes a time where there is a need to perform either CPU or I/O intensive work based on user actions. Whether processing uploaded files, or performing system-wide database updates, developers are increasingly turning to Gearman as a simple way to hand off the heavy lifting to another server to be performed asynchronously.

He's created a basic module that can be downloaded and dropped right into your Magento install to make it work with your Gearman queues. He includes an installation guide and a bit of code on how to make a sample job to run an event and the class sitting on the other side for the worker to use in handling it.

0 comments voice your opinion now!
gearman magento tutorial ecommerce worker


Matthew Weier O'Phinney's Blog:
Writing Gearman Workers in PHP
May 07, 2010 @ 08:11:59

Matthew Weier O'Phinney has a new post today about creating Gearman workers in PHP to be able to handle some of the more complex functionality they want surrounding the Zend Framework.

We're looking at migrating to Git for our primary development on the framework. There are a lot of use cases we need to accommodate [...] Git allows you to define "hooks", scripts that are run at various points of the git commit lifecycle. One hook that can run on the server is called "post-receive". [...] And now we get to Gearman. I realized I could have my post-receive script queue a background task to Gearman. Since this is almost an instantaneous operation, it meant that my hook was completed before Gearman started a worker; if it wasn't, I could always do a sleep() within my worker to ensure it was.

He uses the gearman PECL extension to interface with the Gearman backend service and shows how to push off his post-recieve and rss processes to be handled separately from the current process. He includes the PHP code for both of these processes as well as the actual worker process.

0 comments voice your opinion now!
gearman worker tutorial git process


Content with Style:
PHP worker processes with Beanstalk and Daemontools
April 01, 2010 @ 10:11:49

On the Content with Style blog there's a new post looking at creating a worker process with PHP and the help of two other tools - Beanstalkd and Daemontools.

Sometimes things just get too heavy for a straight forward approach. Memory usage might be too high or interaction might be delayed. In this case it might make sense to queue the task up for later execution.

The technique uses beanstalkd as a messaging queue to handle the requests based on the user's request via the interface the beanstalkd library provides. Then, to keep the queue running in the background and available, he uses daemotools to run a worker process. You can download the complete code for a working example.

0 comments voice your opinion now!
worker daemon process beanstalkd daemontools


Brian Moon's Blog:
Apache Worker and PHP
February 15, 2008 @ 08:43:00

In a recent post to his blog, Brian Moon talks about the experience he's had with using PHP on Apache 2 with a threaded MPM at Dealnews.com.

Well, first, what is an MPM? It stands for Multi-Processing Module. [...] The most commonly used threaded MPM is the Worker MPM. In this MPM, you have several processes that run multiple threads within it. This is the one I will be talking about.

He goes on to describe the "huge memory savings" that using the module got them - using the worker process to increase the child capacity of the Apache instance. He recommends keeping it simple when compiling a server to work with the worker functionality and mentions how it can also help with serving static pages right along side the dynamic ones (without a second server!).

Check out the post for a few more tips.

0 comments voice your opinion now!
apache worker mpm process static dynamic memory



Community Events











Don't see your event here?
Let us know!


composer project symfony2 install language unittest podcast hack application example database introduction release performance security hhvm framework package component facebook

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework