First of all, let me tell you what phpDaemon is. In accordance with its name, it is the network daemon built using libevent2 and eio. phpDaemon has completely asynchronous nature. What does it mean? It means that in strong contradiction to standard Apache plus PHP, phpDaemon’s workers never block (never call sleep() function). If you use PHP, in the standard way, and call any I/O function (e.g. mysql_query, fread/fwrite), these functions block the process until the operation is complete.

Therefore, if your script sends query to database and it takes 1 second, memory taken by PHP process is locked for 1 second.
Therefore, if you have 1 GB of available memory and each Apache worker takes 10 MB (it takes much more in real world), your system can handle ~100 concurrent requests at most. Response delay becomes very valuable thing. If your network or database (or any other I/O source) is lagging under the load, each request will take more time, and requests per second (RPS) goes down.
In the same circumstances, phpDaemon is able to handle all of these requests using ~10 mb per CPU core, and delay of each HTTP reply does not matter at all.
When phpDaemon gets incoming HTTP request, it creates object of YourAppRequest class, and just destroys the object after all.

What types of applications can I develop using this?

Any kind of Web or network application or both in one.

What about memory leaks in long-running phpDaemon workers?

People often say: «you are dumb-ass if you have long-running php processes». But how bad in fact is it?

  1. Yes, there are some internal memory leaks in PHP. But they are not significant (not more than 1-2% at worst case). You can handle a ton of requests and it will grow just a bit. You can catch it and post a bug on
  2. Blocking one PHP process per one running request is the biggest memory leak ever. That is what "standard" SAPIs are doing right now.
  3. Once phpDaemon worker goes over the memory limit (configurable thing), worker starts reloading process: it sends a signal to master process and master spawns new worker-replacer. At the same time, old worker stops accepting new connections, and waits until existing operations are being finished. That is called graceful restart.
  4. Therefore little memory leaks in PHP forces us to do graceful restart of "fat" workers after 50 000 handled requests (real number might be higher, depends on the code). But standard SAPIs are doing restarts after ONE request. No comments.

I have encountered a problem or bug / I have a feature request
What to do?

  1. If you have encountered a problem that not seems like a bug, please send your problem to Mailing list.
  2. If you have encountered something looks like a bug, please open an issue on tracker.
  3. If you have a feature request, please open Feature Request on tracker.

Why am I unable to listen on port 80 with non-root user?

UNIX-like systems require root privilege to bind port < 1024.
If you put in your config something like this:

  1. # Not working example
  2. user johndoe;
  3. group homosapiens;
  4. Pool:HTTPServer {
  5. #...
  6. }

HTTPServer will be loaded after fork (in worker process) and changing user and group (setuid/setgid).
You shall see error message. You are not encouraged to have your workers running under root user.

So if you add "privileged" statement to the config like here:

  1. # Working example
  2. user johndoe;
  3. group homosapiens;
  4. Pool:HTTPServer {
  5. privileged;
  6. #...
  7. }

and if you execute `phpd start` under root user then HTTPServer will be pre-loaded in master process before fork. It shall be working fine.

How about licensing? May LGPL cause troubles for enterprise projects?

Not really. It does not. GNU LGPL (GNU Lesser General Public License) permits any usage in enterprise environment, unlike GNU GPL. We guaratee that you will always have permission to use it in private environment.

The only thing which LGPL requires is that you should open your modifications applied to code of phpDaemon. Any linked code might be private.

I want to use SuperduperfancyDB in my application, but unable to find driver for it. What to do?

  1. If you are a proficient programmer you can build a client by analogy with others. This is not difficult. Consider sharing it.
  2. If you are not enough skilled or just do not want to develop it yourself, you should open a Feature Request on Tracker, and perhaps it will appear in a day or two. Do not sit and wait, just open an FR.

I just installed it, ran `phpd start` and nothing seems to happen. Why?

Logging to TTY is disabled by default. By default, log messages are going only to file.

  1. You can use `phpd log` to interactively watch the log (tail -f).
  2. You can run `phpd start --verbose-tty=1` to watch it your terminal. Useful in development environment, not in production.

How to find and edit configuration?

  1. Default config-path: /etc/phpdaemon/phpd.conf;/etc/phpd/phpd.conf;./conf/phpd.conf
  2. If you want to output your current configuration, use the following command: phpd configtest
  3. You should add necessary sections to your config file, like Pool:FastCGI, MyOwnApp and other.

How can I help?

Please check this section out: Contribute

To be continued.....

Fork me on GitHub