Welcome! Log In Create A New Profile

Advanced

Offloading PHP-FPM to multiple servers

Posted by cody 
cody
Offloading PHP-FPM to multiple servers
December 12, 2013 03:52PM
Hello,

I have a web server that is being overloaded with PHP-FPM requests which is
killing my CPU. I am looking to offload PHP-FPM processing onto multiple
servers with lots of CPU cores. Can someone tell me what all is required
to make this happen, in terms of does the offloading FPM servers need to be
able to see the docroot of the web server? I was thinking a NFS share on
the web server would accomplish this as I would mount the NFS on the FPM
offloading servers.

Is there anything else I am missing that would stop me from simply
deploying some FPM processing servers and using ProxyPass to load balance
the requests to the FPM servers? Is this a common thing people do to serve
up large sites?

Thanks,
Cody

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Dan Farrell
Re: Offloading PHP-FPM to multiple servers
December 12, 2013 05:42PM
Hey there,

You describe a very common setup and this is indeed a good way to spread
load across multiple servers.

However, there are a few gotchas:
On Dec 12, 2013 2:50 PM, "cody" <cbrugh@gmail.com> wrote:

> Hello,
>
> I have a web server that is being overloaded with PHP-FPM requests which
> is killing my CPU. I am looking to offload PHP-FPM processing onto
> multiple servers with lots of CPU cores. Can someone tell me what all is
> required to make this happen, in terms of does the offloading FPM servers
> need to be able to see the docroot of the web server? I was thinking a NFS
> share on the web server would accomplish this as I would mount the NFS on
> the FPM offloading servers.
>
> Is there anything else I am missing that would stop me from simply
> deploying some FPM processing servers and using ProxyPass to load balance
> the requests to the FPM servers? Is this a common thing people do to serve
> up large sites?
>
> Thanks,
> Cody
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "highload-php-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to highload-php-en+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Dan Farrell
Re: Offloading PHP-FPM to multiple servers
December 12, 2013 05:48PM
Let's finish that thought shall we? There are a few pitfalls to avoid:
* probably you're storing sessions in flat files; this means they're only
available on that one server. Sticky sessions break most ha scenarios, and
nfs shared sessions can cause their own issues. use a different session
handler instead; memcache is the de facto solution and is drop in.
*any other filesystem activity will have the same problem. If the php
processes handle uploads, or writing to the local hard drive you might have
issues. This includes UNIX socket connections too!
* i wouldn't put the server assets on nfs myself: id use git or similar to
provide them. The reason is so that compromised servers stay isolated and
so that point of failure is avoided; but having a code base you feel
comfortable delivering to servers id best practice anyway.

Hope it helps!

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Cody Brugh
Re: Offloading PHP-FPM to multiple servers
December 13, 2013 01:30PM
Very good points and thanks Dan!

When the php is offloaded to my fpm farm does that mean if a script say sends a email will that email actually be sent from the fpm farm server? I'm thinking yes as the web server will send all php requests to the fpm farm so anything in the code will be executed from the offloading server.

Does this also mean that if the script connects to SQL then that connection would source from the fpm cluster server and need to hit our SQL box?

Thanks!

> On Dec 12, 2013, at 5:47 PM, Dan Farrell <df00000001@gmail.com> wrote:
>
> Let's finish that thought shall we? There are a few pitfalls to avoid:
> * probably you're storing sessions in flat files; this means they're only available on that one server. Sticky sessions break most ha scenarios, and nfs shared sessions can cause their own issues. use a different session handler instead; memcache is the de facto solution and is drop in.
> *any other filesystem activity will have the same problem. If the php processes handle uploads, or writing to the local hard drive you might have issues. This includes UNIX socket connections too!
> * i wouldn't put the server assets on nfs myself: id use git or similar to provide them. The reason is so that compromised servers stay isolated and so that point of failure is avoided; but having a code base you feel comfortable delivering to servers id best practice anyway.
>
> Hope it helps!
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "highload-php-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Dan Farrell
Re: Offloading PHP-FPM to multiple servers
December 14, 2013 06:34PM
Yes Cody: the servers won't know the others even exist. Nothing will be
shared between then unless you make it so.

For SQL this isn't usually a problem so long as you have ip access (not
UNIX socket) and you SQL is well written concerning locking.
On Dec 13, 2013 6:15 AM, "Cody Brugh" <cbrugh@gmail.com> wrote:

> Very good points and thanks Dan!
>
> When the php is offloaded to my fpm farm does that mean if a script say
> sends a email will that email actually be sent from the fpm farm server?
> I'm thinking yes as the web server will send all php requests to the fpm
> farm so anything in the code will be executed from the offloading server.
>
> Does this also mean that if the script connects to SQL then that
> connection would source from the fpm cluster server and need to hit our SQL
> box?
>
> Thanks!
>
> On Dec 12, 2013, at 5:47 PM, Dan Farrell <df00000001@gmail.com> wrote:
>
> Let's finish that thought shall we? There are a few pitfalls to avoid:
> * probably you're storing sessions in flat files; this means they're only
> available on that one server. Sticky sessions break most ha scenarios, and
> nfs shared sessions can cause their own issues. use a different session
> handler instead; memcache is the de facto solution and is drop in.
> *any other filesystem activity will have the same problem. If the php
> processes handle uploads, or writing to the local hard drive you might have
> issues. This includes UNIX socket connections too!
> * i wouldn't put the server assets on nfs myself: id use git or similar to
> provide them. The reason is so that compromised servers stay isolated and
> so that point of failure is avoided; but having a code base you feel
> comfortable delivering to servers id best practice anyway.
>
> Hope it helps!
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "highload-php-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to highload-php-en+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "highload-php-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to highload-php-en+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready