News Feed
Sections




News Archive
feed this:

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

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


UnixReview.com:
PHP Multi-tasks
September 26, 2006 @ 07:38:07

From UnixReview.com, there's a handy guide to functionality that PHP supports to help you get a handle on things like multiple socket requests - multi-tasking in PHP.

There's quite a bit more to tell, though, about PHP and concurrency. AJAX certainly boasts multi-tasking capabilities, and PHP supports AJAX about as well as the other Web languages support Ajax. An easy conclusion is that, by way of AJAX, therefore, PHP multi-tasks. However, common security, accessibility, and compatibility requirements prevent use of AJAX in many programs.

It's also true that PHP does not "support threads", as many observers put it. Even without AJAX, even without threads, there are still at least two distinct ways to achieve server-side multi-tasking with PHP. Let's look at how the language multi-tasks, and why:

They give an example of one way to fetch information from multiple sources normally (concurrent socket requests) to provide the "low level". They then show an example of how to use pcntl_fork, pcntl_exec, and streams support that can be built into PHP to create a three process function to grab the main pages (and status codes) from each of the sites in an array.

0 comments voice your opinion now!
multitask pcntl_fork pcntl_exec streams socket http multitask pcntl_fork pcntl_exec streams socket http



Community Events





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


laravel community symfony series introduction opinion zendserver package podcast api update framework release library language install deployment list tips interview

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