Monday, September 17, 2007

Introduction

This is a step-by-step tutorial to build a multithreaded daemon in PHP. I will point out several problems caused by a greedy implementation and will give some ways to solve them. I will also have a look at which functions are provided by PHP, what are their advantages and their drawbacks, and how to use them. I will finally give a working implementation of a class that would expose every functions needed to run such a daemon. The implementation will be written in PHP5.

Below are the steps of this tutorial :

  1. Introduction (this part)
  2. Why to use a daemon ?
  3. What is provided by PHP to handle multithreading ?
  4. Roots of a conceptual implementation
  5. The basic implementation of the multithreading class
  6. Limitations of the basic implementation and future work.

20 comments:

Maarten Siersema said...

First of all thank you for this..
But where can I find sections 2-6?

Maarten

KillerWhile said...

Mmh, in fact it takes me more time than planed, so the other articles are a little bit postponed :) But it motivates me to see that this series of articles has interest, so I will higher their priority !

ZVER said...

Hi. i have a very strong need for php multi threading, and very glad to see such things implemented. i hope to use your code with php accelerator such as APC (https://www.blogger.com/comment.do), and simplepie (http://simplepie.org/) to implement consistent rss&atom parser. without your code it would require from me to learn some dot net language or java , and seek for
parser like that great simplepie.. by the way if you have an advice of how can i accelerate even more i will be very thankfull (i hope your script will work well with caching and optimization :) ). Thanks very much for your code.

Michael. thezver@gmail.com

sammiejay said...

Killerwhile: I'm interested too! Keep going :)

Anonymous said...

please, would be great go on with the next sections...

Anonymous said...

I'd be interested in seeing sections 2-6 as well. I've got a need for a system like this and wouldn't mind contributing to an open source solution.

Anonymous said...

yeah, im waiting too :)))

Darren said...

I'm very keen to see how this evolves! :-)

Daniel C said...

Hi, I am also interested in the tutorial, is it still in your TODO list?

greets,
Dani

Anonymous said...

fuck man, leave us dangling why dont you?

Hamish said...

Allo Benoit,

I am interested in writing a php deamon, it's destined to run on a Linksys NSLU2 and hadle various tasks (serial I/O, USB I/O, etc.)

I am very much looking forward to your tutorials!

p.s. I hope it won't be snowing anytime soon and you're bound to strap on the ski's and go out ;)

S├ębastien said...

I'm using Zend Framework with php5 cli.

I need to launch 1000 SNMP queries in parallels.

Any tips ? Does it possible to pthread lib ?

Regards

Anonymous said...

Yes, Plz continue with this artikle. I kinda need it now ;-)

Grtz Jay

Geniium said...

Still waiting for more intresting posts!

Anonymous said...

Well, I was hoping you had finish the tutorial by now... Hope you'll get to it soon.

Nicolas said...

Are you going to finish this ?

Veseliq said...

Hey man. Too bad you didn't finish your tutorial on multithreaded daemon in php. I'm looking for such article and I was quite exited when I found your blog :)

Anonymous said...

I am building a daemon for background processing myself, so would look forward to reading this material :-)

Anton said...

Cross-platform PHP Multithreading Engine
http://anton.vedeshin.com/articles/lightweight-and-multiplatform-php-multithreading-engine

Fernando Javier said...

Yes, it would be interesting to read you.

Waiting for it. ;o)

Regards,
<?=Pampa?>