On 24 Mar 2010, at 11:55, Rene Veerman wrote:
> As a way to take a few steps back from the kinda heated "when will php
> grow up and support threading" thread, i'm requesting you people list
> how you scale from 1 server to many servers; what's called cloud
> In particular, i'm interested in how to set up an application that
> deals with great amounts of input from many 3rd-party servers, and say
> a million concurrent viewers who need html calculated from those input
> So this goes beyond 1 mysql server, and beyond 1 php server.
> Let's hear it, coz quite frankly i have my doubts about php's ability
> to scale to cloud computing.
The way you're using the term cloud computing differs from the generally
accepted definition, which is "delivering hosted services over the Internet".
What you're talking about is scaling an application beyond a single server
which is a different, albeit usually related, beast.
There is no single or "right" way to implement a scalable web application but
there are some key principles. The main principle that enables maintainable
scalable systems is layers. If you build your application in a layered fashion,
such that no layer knows how the other layers work, you can modify any of the
layers in any way you need to when scalability issues arise.
Your hardware setup will depend on the application and usage patterns, but some
combination of load balancers, application servers and database servers is
pretty normal. You may also find servers dedicated to caching and offline
processing useful to achieve your goals.
Architecture-wise you'll want to make extensive use of caching to lighten the
load on the database, and you'll want to make sure that you perform no
processing during a request that could wait to be processed offline.
The main site I maintain has two load balancers at the front running nginx,
three application servers running FastCGI PHP processes, two database servers
in a master/slave arrangement, a separate static server and two offline
processing servers. The application servers all have memcached instances for
caching purposes and each runs its own instance of Sphinx to localise the
That setup, combined with a shared-nothing approach to the application design
means I have a highly scalable system. To add capacity I simple need to add
servers in whichever group is having issues. Due to the nature of the
application I'm yet to come close to having issues with the number of
concurrent writes to the database, but when I do I already plan to add another
master server such that I have a master/master/slave setup.
Unless you do start getting the sort of traffic that Facebook are blessed with
you will be able to get a long way with this type of arrangement. And with a
modular, layered approach to the application design I don't see any reason why
I can't handle any scalability issue that's likely to come along with a minimum
of fuss and cost.
The key think to remember is that scalability is not the same as performance.
They're barely even related. What, specifically, makes you doubt PHP's ability
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php