<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Thu, 24 May 2012 06:34:27 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[James Cohen's Blog: Poor Man's Parallelization for Batch Processing Jobs]]></title>
      <guid>http://www.phpdeveloper.org/news/16355</guid>
      <link>http://www.phpdeveloper.org/news/16355</link>
      <description><![CDATA[<p>
<i>James Cohen</i> has a quick post about what he calls a <a href="http://webmonkeyuk.wordpress.com/2011/05/17/poor-mans-parallelization-for-batch-processing-jobs/">"poor man's parallelization"</a> for working with batch jobs. It takes in parameters that tell it which set of jobs to run through when looping.
</p>
<blockquote>
One common problem that I've seen time and time again with batch processing jobs (generally cronjobs) is that when they're written they run quickly. Over time their workload grows until eventually it's unacceptably slow. [...] To create a simple of way of separating the jobs in a consistent way we can use the <a href="http://en.wikipedia.org/wiki/Modulo_operation">modulus operator</a>. It just calculates the remainder of two numbers. It's a common arithmetic operator in almost all languages so this technique is pretty portable.
</blockquote>
<p>
His proof-of-concept script takes in two parameters, the starting job number and the number to increment. His example is user IDs, but this type of script could be used for anything with an ID number. The script is then run from the command line with the parameters of your choosing.
</p>]]></description>
      <pubDate>Wed, 18 May 2011 11:56:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David M&uuml;ller's Blog: Parallel processing in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16132</guid>
      <link>http://www.phpdeveloper.org/news/16132</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>David M&uuml;ller</i> has taken a look at <a href="http://www.d-mueller.de/blog/parallel-processing-in-php/">parallel processing in PHP</a> using a few different methods - system calls, <a href="http://php.net/fork">fork</a>, and <a href="http://php.net/curl">curl</a>.
</p>
<blockquote>
Since PHP does not offer native threads, we have to get creative to do parallel processing. I will introduce 3 fundamentally different concepts to emulate multithreading as good as possible.
</blockquote>
<p>
For each of the technologies mentioned above, he provides a simple bit of sample code that does simple tasks like echoing out strings and writing to files. He also includes some benchmarks (take them with a grain of salt) of the three different methods showing how many iterations they could run through in ten seconds. He includes the benchmarking script if you'd like to try it out yourself.
</p>]]></description>
      <pubDate>Thu, 31 Mar 2011 13:41:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder's Blog: You want to do WHAT with PHP? Chapter 6 & 7]]></title>
      <guid>http://www.phpdeveloper.org/news/15130</guid>
      <link>http://www.phpdeveloper.org/news/15130</link>
      <description><![CDATA[<p>
<i>Kevin Schroeder</i> has posted excerpts from the <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8a4c56">sixth</a> and <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8f71e1">seventh</a> chapters from his "You Want To Do WHAT With PHP?" book.
</p>
<p>
<a href="http://www.eschrade.com/page/want-what-with-chapter-4c8a4c56">Chapter 6</a> focuses on asynchronous processing and the excerpt talks about doing it with a little big of encryption on the side.
</p>
<p>
In the excerpt from <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8f71e1">Chapter 7</a> he looks at a more structured way to access files rather than just the random <a href="http://php.net/fopen">fopen</a> or <a href="http://php.net/file_get_contents">file_get_contents</a>. There's a code example in this one showing how to get the header information off of a file for things like file type, last modified time, a header checksum and the file's permissions.
</p>]]></description>
      <pubDate>Wed, 15 Sep 2010 08:16:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[IBM developerWorks: Efficient mathematical processing using Scilab through PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14224</guid>
      <link>http://www.phpdeveloper.org/news/14224</link>
      <description><![CDATA[<p>
New on the IBM developerWorks, there's an article looking at <a href="http://www.ibm.com/developerworks/opensource/library/os-php-scilab/index.html?S_TACT=105AGY46&S_CMP=HP">using the Scilab software</a> integrated into PHP to perform some more complicated mathematical processing.
</p>
<blockquote>
Scripting languages like Ruby, Python, and PHP power modern-day server-side Web development. These languages are great because you can easily and rapidly build Web sites. However, their downfall is their inefficiency with complicated algorithms, such as those found in mathematics and the sciences. [...] In this article, we'll investigate one particular way to merge the power of a particular bit of scientific software - Scilab - with the ease of development and Web-friendliness of a server-side language: PHP. 
</blockquote>
<p>
Your script uses the <a href="http://www.scilab.org/">Scilab</a> tool from the command line, called via something like <a href="http://php.net/exec">exec</a>, and parsing the output to spit the results back out to the viewer. They show how to create two pages with form elements for allowing the user to interact with the script and one that helps you generate a graph based on some results.
</p>]]></description>
      <pubDate>Mon, 22 Mar 2010 11:55:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPClasses.org Blog: Distributing PHP processing with Gearman]]></title>
      <guid>http://www.phpdeveloper.org/news/13579</guid>
      <link>http://www.phpdeveloper.org/news/13579</link>
      <description><![CDATA[<p>
On the PHPClasses blog there's <a href="http://www.phpclasses.org/blog/post/108-Distributing-PHP-processing-with-Gearman.html">a new post</a> looking at using the <a href="http://gearman.org/">Gearman</a> framework with PHP via a PECL extension.
</p>
<blockquote>
Gearman is a generic framework to distribute processing jobs to separate processes in the same machine or other machines in a cluster. It allows your application to perform tasks in parallel, balance the processing load, and even invoke code written in other languages. The "Gearman" word is an anagram of "manager". Its purpose is solely to dispatch jobs that need to be executed, but Gearman just by itself does not do anything useful.
</blockquote>
<p>
In his example he sets up a simple "Hello World" processing queue including the command line to start up the Gearman server and the PHP you'll need to push in a request, grab the status and see the percentage of it that's been completed.
</p>]]></description>
      <pubDate>Mon, 23 Nov 2009 12:58:10 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: The Mysteries Of Asynchronous Processing With PHP - Part 2 (CLI applications)]]></title>
      <guid>http://www.phpdeveloper.org/news/13306</guid>
      <link>http://www.phpdeveloper.org/news/13306</link>
      <description><![CDATA[<p>
In the <a href="http://blog.astrumfutura.com/archives/418-The-Mysteries-Of-Asynchronous-Processing-With-PHP-Part-2-Making-Zend-Framework-Applications-CLI-Accessible.html">second part</a> of his series looking at asynchronous processing in PHP applications, <i>Padraic Brady</i> lays the ground work for the third part and shows how to work with command line Zend Framework applications.
</p>
<blockquote>
Part 2 is a tangential detour into how to make a Zend Framework based application accessible from the command line before we delve into examples using this in future parts of the series. If you are not a Zend Framework user, I'm sure you can find relevant material online for your own preferred framework though the ZF pieces may still have some usefulness in understanding the approach from an MVC perspective.
</blockquote>
<p>
In his examples he skips over the basics of using a command line application and jumps right to things like argument handling, creating a custom router and making a custom "calling script" to handle the configuration of the CLI application.
</p>]]></description>
      <pubDate>Wed, 30 Sep 2009 08:32:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Juozas Kaziukenas' Blog:  Prevent scripts from being killed]]></title>
      <guid>http://www.phpdeveloper.org/news/12216</guid>
      <link>http://www.phpdeveloper.org/news/12216</link>
      <description><![CDATA[<p>
<i>Juozas Kaziukenas</i> has <a href="http://dev.juokaz.com/php/prevent-scripts-from-being-killed">a helpful tip</a> you can use on those long-running scripts to keep going - the <a href="http://php.net/set_time_limit">set_time_limit</a> function.
</p>
<blockquote>
I have some very time consuming scripts running through <a href="http://en.wikipedia.org/wiki/Cron">CRON</a> - some nice web scrapping jobs. They are not processing-intense, but rather slow because of slow websites. All these jobs are really hard to divide in to separate scripts (another article), so one script should have no limits to run for hours. However, web servers don't like it by default.
</blockquote>
<p>
He show how you can use the set_time_limit function to free your script of the timeout limitation (which can be a good and bad thing) or having your script output something, like a "processing" message, as it runs through the loop to keep the timeout away. You can also use the <a href="http://php.net/ignore_user_abort">ignore_user_abort</a> function to continue the process even if the user hits the stop button or otherwise closes the request.
</p>]]></description>
      <pubDate>Thu, 26 Mar 2009 13:18:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP in Action: Real programming with PHP 5.3 (part 1): array processing]]></title>
      <guid>http://www.phpdeveloper.org/news/12170</guid>
      <link>http://www.phpdeveloper.org/news/12170</link>
      <description><![CDATA[<p>
On the PHP in Action blog, a new series has been kicked off with <a href="http://blog.agilephp.com/2009/03/19/real-programming-with-php-53-part-1-array-processing/">this first part</a> looking at "real programming" in the upcoming PHP 5.3 release.
</p>
<blockquote>
You may have heard of the new features that are scheduled for PHP 5.3, but who knows what they can be used for in real programming? I took the time for some experimental research, and came up with a few examples.
</blockquote>
<p>
This <a href="http://blog.agilephp.com/2009/03/19/real-programming-with-php-53-part-1-array-processing/">first part</a> focuses on the new lambda/closures functionality that will come with the new release. He compares it to the <a href="http://php.net/create_function">create_function</a> syntax currently offered, specifically when it comes to sorting and manipulating arrays.
</p>]]></description>
      <pubDate>Thu, 19 Mar 2009 11:18:20 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ibuildings Blog: Boost performance with parallel processing]]></title>
      <guid>http://www.phpdeveloper.org/news/11798</guid>
      <link>http://www.phpdeveloper.org/news/11798</link>
      <description><![CDATA[<p>
On the Ibuildings blog today there's <a href="http://www.ibuildings.com/blog/archives/1539-Boost-performance-with-parallel-processing.html">a new post</a> from <i>Martin Roest</i> looking at parallel processing in PHP scripts and how it can help you with performance and simplifying your applications.
</p>
<blockquote>
The idea of parallel processing is when you take an atomic transaction or operation called a 'process' and run a couple of those at the same time. [...] In this example I had a PHP CLI script. The purpose of this script was to process remote documents and save it local. It fetched the document from a remote location, processed it and saved the result local - let's call this the transaction. Transactions were done sequentially. It took about 1 second for a transaction to complete and the script had to do roughly 3500 transactions.
</blockquote>
<p>
Obviously, this script/testing method was not very effective, so he went searching for an alternative. The best option came in the shape of forking processes - spawning off a separate script (via PHP's forking functionality) to do the work on one or multiple entries. It uses the <a href="http://php.net/pcntl_fork">pcntl_fork</a> and <a href="http://php.net/pcntl_waitpid">pcntl_waitpid</a> functions to spawn and manage these children. Once they're all finished - working in parallel - they return back to the main script to wait for the slower ones to catch up.
</p>]]></description>
      <pubDate>Fri, 23 Jan 2009 07:51:05 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[John Lim's Blog: Parallel Processing in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/11053</guid>
      <link>http://www.phpdeveloper.org/news/11053</link>
      <description><![CDATA[<p>
<i>John Lim</i> has two new posts covering parallel processing in PHP and how to use this "divide and conquer" idea to not only speed up your code but to make it more maintainable down the road.
</p>
<p>
In <a href="http://phplens.com/phpeverywhere/?q=node/view/254">the first post</a>:
</p>
<blockquote>
One problem we were having is that some of our batch processing jobs were taking too long to run. In order to speed the processing, we tried to split the processing file into half, and let a separate PHP process run each job. [...] Here is our technique for running multiple parallel jobs in PHP. In this example, we have two job files: j1.php and j2.php we want to run.
</blockquote>
<p>
The code is included for the job files and the "controller" that manages them. In the <A href="http://phplens.com/phpeverywhere/?q=node/view/255">second article</a>, he builds on this and shows a more practical example - finding the median of a set of records out of a database.
</p>]]></description>
      <pubDate>Mon, 22 Sep 2008 08:47:14 -0500</pubDate>
    </item>
  </channel>
</rss>

