Current time: 11-26-2024, 01:52 PM Hello There, Guest! (LoginRegister)


Post Reply 
php-fpm support
Author Message
pulponair Offline
Junior Member
*

Posts: 10
Joined: Jun 2010
Reputation: 0
Post: #1
php-fpm support
Hi there,

as of version php 5.3.3 php ships with php-fpm.

One mayor benefit of using the fpm SAPI over regular fastcgi/fcgi starters is the fact, that i use a single root php process which enables us to share shm (shared memory - e.g. used by opcode caches) accross all runing php process.
This would dramatically increase opcode cache efficiency while it decreases overall memory consumption.

Another benefit is the fact that the php-fpm deamon is cabable of its own dynamic adaptive process spawning. So the php process handling can be handed over completly to php-fpm, instead of using a creppy mixture of fastcgi-pm and php's own child managment.

See http://php-fpm.org/ for the big picture.

I worked out a ispcp apache configuration (see below) and tested it in various scenarios (posted to php-highload as well).

Besides the apache configuration there has to be a php-fpm configuration which is pretty straight forward.

Note: You need mod_fastcgi, since mod_fcgi is'nt cabable of anything similar to FastCGIExternalServer

For a full ispcp integration the ispcp engine needs to be modified to manage the fpm configuration file.

Apache configuration is just a template matter.

If anyone could guide me (haven't worked with perl for decades Wink ). I could come up with a patch.

Within mod_fastcgi.conf (global):
Code:
# We want to have all sockets within this directory
FastCgiIpcDir /var/lib/apache2/fastcgi2

# Register a cumstom handler to .php .php5 scripts
AddHandler php-fastcgi .php .php5

# Point this handler to /php5/php-fpm
Action php-fastcgi /php5/php-fpm

# Set the register fastcgi-script handler +
# whatever you want for a fpm request.
<Location /php5/php-fpm>
       SetHandler fastcgi-script
       Options +ExecCGI
</Location>

#Set mime type
AddType application/x-httpd-php .php .php5

Per vhost:
Code:
# Alias /php5/ to /var/www/fcgi/www.example.com/  
ScriptAlias /php5/ /var/www/fcgi/www.example.com/

# Pickup request and forward it to the particular fpm socket.
FastCGIExternalServer /var/www/fcgi/www.example.com/php-fpm -socket
www.example.com

Cheers,
Nikolas
08-17-2010 10:45 PM
Find all posts by this user Quote this message in a reply
RatS Offline
Project Leader
******

Posts: 1,854
Joined: Oct 2006
Reputation: 17
Post: #2
RE: php-fpm support
The required changes for the engine must be quite simple:

ispcp-dmn-mngr needs to copy the file to the right directory (/var/www/fcgi/{DMN-NAME}/php5/ I guess). How to do this just check how the php.ini-File for users is created.

Additionally you might change the Makefile inf the config dir and add the template for the php-fpm.ini. If you need to replace variables, you can do this in the ispcp-dmn-mngr, too.
If you succeeded, please create a ticket with as most complete patch.

It looks really interesting for us, too.

Thanks for the suggesting. On questions we will help you!
08-19-2010 05:08 AM
Visit this user's website Find all posts by this user Quote this message in a reply
gOOvER Offline
Banned

Posts: 3,561
Joined: Jul 2007
Post: #3
RE: php-fpm support
Why not open a Ticket. So we don't forget it Smile
08-19-2010 06:33 AM
Visit this user's website Find all posts by this user Quote this message in a reply
pulponair Offline
Junior Member
*

Posts: 10
Joined: Jun 2010
Reputation: 0
Post: #4
RE: php-fpm support
(08-19-2010 05:08 AM)RatS Wrote:  The required changes for the engine must be quite simple:

ispcp-dmn-mngr needs to copy the file to the right directory (/var/www/fcgi/{DMN-NAME}/php5/ I guess). How to do this just check how the php.ini-File for users is created.

Additionally you might change the Makefile inf the config dir and add the template for the php-fpm.ini. If you need to replace variables, you can do this in the ispcp-dmn-mngr, too.
If you succeeded, please create a ticket with as most complete patch.

It looks really interesting for us, too.

Thanks for the suggesting. On questions we will help you!

Unfortunatly it's not that easy, since the domain mgr has to take care of the php5-fpm.conf file (configuration for the fpm deamon), which defines the settings and socket for every single pool (domain in our case).

It looks like this:
Code:
log_level = debug
daemonize = yes


[admin.debian.example.com]
listen = /var/lib/apache2/fastcgi2/admin.debian.example.com

user = vu2000
group = vu2000

pm = dynamic
pm.max_children = 50
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 500


[test1.example.com]
listen = /var/lib/apache2/fastcgi2/test1.example.com

user = vu2001
group = vu2001

pm = dynamic
pm.max_children = 50
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 500


[test2.example.com]
listen = /var/lib/apache2/fastcgi2/test2.example.com

user = vu2002
group = vu2002

pm = dynamic
pm.max_children = 50
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 500

As you can see there is a section for every domain, so the domain manager needs to adjust it on domain changes (add/delete). Quite similar to way ispcp handles vhost "entrys" at the moment.

Further more, fpm isn't capable of handling different php.ini files atm. Though it's possible to override/set ini settings pool wise. Which should be sufficient.

Cheers,
Nikolas
Ticket created:
http://isp-control.net/ispcp/ticket/2426
(This post was last modified: 08-19-2010 07:08 PM by pulponair.)
08-19-2010 06:57 PM
Find all posts by this user Quote this message in a reply
Nuxwin
Unregistered

 
Post: #5
RE: php-fpm support
Hello ;

Sorry but php-fpm is available under Squeeze ?
08-19-2010 11:02 PM
Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #6
RE: php-fpm support
I don't see php-fpm as a good solution for ispcp *as of now*. Basically, from what I've seen, we need to run a separate php manager process per user. As many of us already know, this is *very bad* for shared hostings where you may have hundreds or thousands of users.

Can you clarify on this front pulponair?
08-19-2010 11:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
pulponair Offline
Junior Member
*

Posts: 10
Joined: Jun 2010
Reputation: 0
Post: #7
RE: php-fpm support
(08-19-2010 11:13 PM)kilburn Wrote:  I don't see php-fpm as a good solution for ispcp *as of now*. Basically, from what I've seen, we need to run a separate php manager process per user. As many of us already know, this is *very bad* for shared hostings where you may have hundreds or thousands of users.

Can you clarify on this front pulponair?

You are wrong, you are running just one root pm process which manages it's childs dynamically (for all pools/vhosts/user)...

This is how a the processtree looks for the sample i posted above:
Code:
├─php5-fpm(2173)─┬─php5-fpm(2176,vu2000)
                 ├─php5-fpm(2177,vu2001)
                 ├─php5-fpm(2476,vu2001)
                 └─php5-fpm(2178,vu2002)

Of cource the number of childprocesses will increase/decrease depeding on the load and the limits for the particular pool/user/domain/vhost. The whole concept is much better than that fastcgi /starter script thing which looks like this (as we all know):
http://yfrog.com/e4fastcgip

Hope this clears up things a little.

Cheers,
Nikolas
(08-19-2010 11:02 PM)Nuxwin Wrote:  Hello ;
Sorry but php-frm is available under Squeeze ?

Obviously not since Squeeze shipps with php 5.3.2 while fpm has been included in 5.3.3. There are dotdeb packages avaible and patches for 5.3.2.

Cheers,

NIkolas
(This post was last modified: 08-19-2010 11:26 PM by pulponair.)
08-19-2010 11:22 PM
Find all posts by this user Quote this message in a reply
Nuxwin
Unregistered

 
Post: #8
RE: php-fpm support
Ok if not available in official repository, I don't recommend it for ispCP too.

Code:
├─php5-fpm(2173)─┬─php5-fpm(2176,vu2000)
                 ├─php5-fpm(2177,vu2001)
                 ├─php5-fpm(2476,vu2001)
                 └─php5-fpm(2178,vu2002)

Hu, what if the parent process die for any reasons ?
08-19-2010 11:33 PM
Quote this message in a reply
pulponair Offline
Junior Member
*

Posts: 10
Joined: Jun 2010
Reputation: 0
Post: #9
RE: php-fpm support
Hi,
(08-19-2010 11:33 PM)Nuxwin Wrote:  Ok if not available in official repository, I don't recommend it for ispCP too.
I understand you concerns.
But the fact that it's not officially available for debian at the moment does not mean that it's not worth thinking about integration, right?

(08-19-2010 11:33 PM)Nuxwin Wrote:  Hu, what if the parent process die ?

Well, the parent process does not process php request itself it's just the processmanager. So for what reasons should it die? (Except if something goes really terrible wrong - but that's bad for any kind of software Wink ).

There is always a root process which screws up the whole chain when it dies. If e.g the apache root process dies the whole webserver is gone...so that shouldn't be argument.

Cheers,
NIkolas
08-19-2010 11:48 PM
Find all posts by this user Quote this message in a reply
pulponair Offline
Junior Member
*

Posts: 10
Joined: Jun 2010
Reputation: 0
Post: #10
RE: php-fpm support
Hi,

any new opinions/evolution on this - now that fpm is part of php for more than a year?

here are some resources that describe the actual problem:
http://www.brandonturner.net/blog/2009/0...ode_cache/

And here is what the php folks recommend (using fpm) Wink.
https://bugs.php.net/bug.php?id=57825

Cheers,
Nikolas
11-02-2011 08:16 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)