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

Mikko Koppanen:
Working on images asynchronously
Dec 16, 2013 @ 16:45:35

Mikko Koppanen has a new post to his site today about working with images asynchronously - the "offline" processing of things like user uploaded images using a queuing system.

To get my quota on buzzwords for the day we are going to look at using ZeroMQ and Imagick to create a simple asynchronous image processing system. Why asynchronous? First of all, separating the image handling from a interactive PHP scripts allows us to scale the image processing separately from the web heads. [...] Secondly, separating the image processing from a web script can provide more responsive experience to the user. This doesn’t necessarily mean faster, but let’s say in a multiple image upload scenario this method allows the user to do something else on the site while we process the images in the background.

He also includes a "barebones" example of how the system would work. The first Worker script makes the connection to the queue system and sends the data off for handling. The second script does most of the actual work, pulling in the image and using Imagick to create a thumbnail image. Finally he includes an example of the use of the workers in combination to send the image data for processing.

tagged: image asynchronous processing zeromq thumbnail imagick

Link: http://valokuva.org/working-on-images-asynchronously/

Gonzalo Ayuso:
Enqueue Symfony’s process components with PHP and ZeroMQ
Apr 09, 2013 @ 16:11:59

Gonzalo Ayuso has a new post today showing how he set up queuing with ZeroMQ and Symfony components and React.

Today I’d like to play with ZeroMQ. ZeroMQ is a great tool to work with sockets. I will show you the problem that I want to solve: One web application needs to execute background processes but I need to execute those processes in order. Two users cannot execute one process at the same time. OK, if we face to this problem we can use Gearman. I’ve written various posts about Gearman (here and here for example). But today I want to play with ZeroMQ.

He uses React and some ZeroMQ bindings and Symfony's Process component to make a simple client and server for working with the queue and processes. A screencast is included in the post showing them making the connection and adding the new process. The full code can be found on github (or installable via Composer)

tagged: zeromq symfony component process react server client tutorial

Link: http://gonzalo123.com/2013/04/08/building-a-zeromq-enqueue-with-php

Rasmus Lerdorf's Blog:
ZeroMQ + libevent in PHP
Sep 29, 2011 @ 16:45:39

Rasmus Lerdorf has a new post to his blog sharing the results of some "investigative hacking" he did to see if making ZeroMQ and libevent work together was difficult. Thankfully, the answer was "not hard at all".

While waiting for a connection in Frankfurt I had a quick look at what it would take to make ZeroMQ and libevent co-exist in PHP and it was actually quite easy. Well, easy after Mikko Koppanen added a way to get the underlying socket fd from the ZeroMQ PHP extension. To get this working, install the PHP ZeroMQ extension and the PHP libevent extension.

He includes a sample script show the results of his work, a basic server and client that sends a request to the ZeroMQ server and fires off an event using the libevent library (via PHP's extension. You can find out more about using these two libraries in the PHP manual - libevent and ZeroMQ

tagged: zeromq libevent extension library queue example

Link:


Trending Topics: