News Feed
Sections




News Archive
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

blog comments powered by Disqus

Similar Posts

DevShed: Handling File Data with PHP (Reading & Seeking)

Justin Silverton\'s Blog: Using PEAR Cache_Lite for High Performance

Brandon Beasley's Blog: Codeigniter Vanity URLs

Zend Developer Zone: Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 2)

Chris Hartjes' Blog: Handling Multiple Environments In Your PHP Application


Community Events





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


zendserver laravel development api conference symfony deployment release list language framework introduction threedevsandamaybe tips bugfix code series community interview podcast

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