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

Reddit.com:
Multithreading in PHP with pthreads
August 05, 2013 @ 11:21:31

On Reddit.com there's a post from krakjoe talking about using multithreating in PHP, specifically with pthreads. Unfortunately, there's several misconceptions about the pthreads (and concurrency) that still makes it difficult in PHP. The post lists a few of them:

  • PHP is not thread safe, there are lots of extensions that will give your application cooties.
  • pthreads is old fashioned
  • pthreads does not include everything you need to execute safely
  • pthreads unsafely shares memory among contexts in order to provide concurrent functionality
  • pthreads is beta and should be avoided at all costs

The author points out that pthreads are still in more of a "beta" state and probably shouldn't be used in production (though some do):

Multi-threading in PHP sounds like some sort of voodoo, for so long it's been something that was either impossible in the minds of php programmers, or a bad idea to try and emulate. pthreads doesn't emulate anything, it leverages bundled functionality and the object API to provide true userland multi-threading.
0 comments voice your opinion now!
multithread pthreads extension summary misconceptions

Link: http://www.reddit.com/r/PHP/comments/1jo517/multithreading_in_php_with_pthreads/

Ant Phillips' Blog:
Singletons, BIRT, Theads and PHP
February 18, 2009 @ 12:55:47

In doing some work with Zero (PHP in Java) and the Eclipse Business Intelligence and Reporting Tools project, Ant Phillips had some troubles with multithreaded PHP processes and wanting them all to use the same BIRT instance insted of spawning their own.

The problem is that BIRT needs to be started once, and only once, in any given process. Once it has been started up, then it is plain sailing to load reports and render them to HTML. The BIRT runtime should be kept around until the process shuts down.

Two problems came up with this approach - if each PHP process makes its own BIRT process any settings/current data will be wiped out and the BIRT instance would go away whenever the PHP script finishes. He found something that solves both of these problems - the Zero Global Context. Its a "storage area" that can contain just about anything. He used it to store the BIRT runtime until its told to finish and die off.

1 comment voice your opinion now!
birt java zero multithread singleton process global context


IBuildings Blog:
Multithreading in PHP with CURL
April 01, 2008 @ 16:23:08

As mentioned on the Zend Developer Zone, there's a new tutorial posted on the IBuildings blog (by Lineke Kerckhoffs-Willems) about performing some multi-threading magic in PHP with the help of cURL.

Each PHP request is a separate thread. There are some workarounds like using pcntl_fork, starting multiple commandline php processes using the exec command or even using ajax. Another possibility is using the Curl library. Besides the basic functions described above Curl offers the "multi" functions for retrieving content from several url's at the same time.

Examples are included showing how to make these "multi" requests via PHP's cURL support (calling URLs with a "seconds" value on the end).

0 comments voice your opinion now!
multithread curl example tutorial multiple request


PHP 10.0 Blog:
We are doomed! (and Ticks in PHP)
June 20, 2007 @ 10:29:00

In this new post to the PHP 10.0 blog, Stas mentions the "impending doom" of PHP that's been going around the community, including in this post on the TechRepublic site.

He does, however, branch off into something much more interesting that seems to be somewhat ignored by developers - the use of ticks on their code:

This is something named "ticks" - I wonder how many of the PHP developers heard about it and of those how many actually used it. Could it be used for offloading long-running I/O-bound tasks or grouping them together (e.g. so we could wait for DB and HTTP in parallel and not sequentially)? Would there be any use at all for such functionality and if so - how it's supposed to work? I.e. how would you know it's done and how you would collect and use the results?

It's suggested in the comments that it could be used for any kind of application that might need the pseudo-multithreading it offers (including something like scripts needing multiple TCP connections).

0 comments voice your opinion now!
doom tick multithread declare construct doom tick multithread declare construct


AlternateInterior.com:
Benchmarking PHP Threads
May 07, 2007 @ 08:52:00

In two previous posts, the AlternateInterior blog looked at working with threading in PHP. They continue along this path with this new post today - benchmarking some of their threading techniques.

All threads can now both hear and report on conditions. A problem with the original send/receive mechanism made threads hang the controlling thread while long operations were occurring.

After updating some of their HVAC class to make it a little easier to understand/use, they ran some benchmarks on running processes two different ways - multithreaded and sequential.

The package is available for download if you'd like to work with it/run the tests yourself.

0 comments voice your opinion now!
thread benchmark download multithread sequential thread benchmark download multithread sequential



Community Events





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


code laravel developer list install podcast language framework introduction configure release series application library interview community wordpress bugfix threedevsandamaybe api

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