Scalability

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Scalability

Post by Theory? »

In lieu of a long story, here's the question in a nutshell:

How does PHP stack up in scalability vs. RoR and Java. I know Java is obviously the most scalable, but it's cumbersome, slow, and in the end I'd rather avoid it altogether if possible. I keep hearing mixed things about RoR and it's capabilities, but the fact that some people are certain it can't scale, I figured I'd come to the experts. I know PHP isn't exactly a scaling machine, but given that some rather large sites run on it and experience minimal problems, I have to wonder what the breaking point is for either language.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Scalability

Post by Christopher »

Scaling has little to do with the programming language. Both PHP and Java are proven to scale equally well -- as demonstrated by many huge sites. RoR being a rapid development framework is not focused on scaling and has problems. However if you are an expert in RoR I am sure you can get it to scale.

I am actually interested in this subject. Specifically, what are some scalable architectures for PHP that are reasonably easy to install and maintain. And not just scalability, but high(er) availability is probably also a goal.

There are certainly a number of common tools like MySQL replication, memcache, PHP's ability to do database backed session management, etc. that would probably be used for this kind of solution.
(#10850)
sike
Forum Commoner
Posts: 84
Joined: Wed Aug 02, 2006 8:33 am

Re: Scalability

Post by sike »

simple scaling

- one big db server
- nas (for global files)
- loadbalancer with session support
- some http servers

if the bottleneck becomes your db server you will need to setup replication and implement your data access with heartbeat support (a way to see which db server is available and ready to handle some work). from this point on you scale simply by adding http and mysql servers as needed. that's the nice thing about stateless requests - they scale well.

i am no java expert but as long as you need to use application servers like tomcat you can't scale that easy because the servers have state and that would need to be shared. there might be solutions for this so if someone knows about scaling java sites step up (: i am interessted to learn how they do things.

cheers
chris
Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Re: Scalability

Post by Theory? »

Also what about PHP's speed when paired with other databases like PostgreSQL?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Scalability

Post by alex.barylski »

PHP speed has nothing to do with other databases... :?

The PHP extensions are just thin wrappers around the original RDBMS API so as fast as you can get MySQL to run using Ruby or ASP.NET or Java, is the same speed you'll get out of PHP as well.

I've been gaining interest in load balancing as our own systems begin to grow...

What we have right now is a power computer running the RDBMS (MSSQL and MySQL) and a lesser server running LA_P (where _ would normal be MySQL).

There is a Apache module called mod_proxy which I believe allows you to daisy chain/round robin several servers togather to handle user requests, each would ultimately use the same MySQL server though.

I tend to keep SQL queries very simple, operating on a single table only. This results in fast queries and probably slower performance on the PHP side of things (perhaps a little backwards -- but I am far more familiar with optimizing PHP and it's various services than I am SQL tuning). We still don't serve enough traffic to justify implementing mod_proxy but the ide makes sense.

My focus is almost always on application level caching, as you will typically yield greatest results from that.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Scalability

Post by kaisellgren »

PCSpectra wrote:so as fast as you can get MySQL to run using Ruby or ASP.NET or Java, is the same speed you'll get out of PHP as well.
Not entirely... think about the new MYSQLND library they made for 5.3, it is noticeably faster than the old LIBMYSQL used in <5.3. MySQL on 5.3 does run faster than PostgreSQL on 5.3, but this is almost insignificant though and the database performance comes from elsewhere as we know.
PCSpectra wrote:What we have right now is a lesser server running LA_P (where _ would normal be MySQL).
Before spending any money on load balancing, I highly suggest to drop Apache - it's a BIG resource hog. Personally I have found a combination of nginx for static files + Cherokee for PHP files a good combo. On my VPS, a switch from Apache to that setup yielded in about 60-90 MB of free RAM, the idle process usage has went from the usual ~9% to ~21% (approximate values), and the whole site loads faster.

Take a look: http://www.cherokee-project.com/doc/

I highly recommended it.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Scalability

Post by Eran »

If you're interested in scalability, check out High Scalability - http://highscalability.com/, a site that covers the architecture of high-profile sites and offers insight into the solutions they chose.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Scalability

Post by VladSun »

A friend of mine has done some benchmarking "Apache vs nginx testing". While you won't be able to understand the text part, the figures in the article are enough :)

http://www.gat3way.eu/index.php?mact=Ne ... eturnid=15
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Scalability

Post by alex.barylski »

VladSun: Seems Apache (mod_prefork) does alright when compared to the others...no???

Not that anyone cares, but if I were to switch to another server it would probably lighttpd. :P

EDIT | Good to see you around VladSun...haven't seen you in a while (not sure if you were just lurking) but I was getting worried you disappeared for good and I'd have no one to help me with my *nix problems anymore. :) :drunk:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Scalability

Post by VladSun »

PCSpectra wrote:VladSun: Seems Apache (mod_prefork) does alright when compared to the others...no???

Not that anyone cares, but if I were to switch to another server it would probably lighttpd. :P
In two of the comments in the article, system administrators explain that with nginx machine load is 2-4 times less than with Apache.
PCSpectra wrote:EDIT | Good to see you around VladSun...haven't seen you in a while (not sure if you were just lurking) but I was getting worried you disappeared for good and I'd have no one to help me with my *nix problems anymore. :) :drunk:
Too much of deadlines lately :)
There are 10 types of people in this world, those who understand binary and those who don't
maggie59
Forum Newbie
Posts: 3
Joined: Mon Jun 29, 2009 9:40 am

Re: Scalability: MySQL 5.4.1?

Post by maggie59 »

kaisellgren wrote:MySQL on 5.3 does run faster than PostgreSQL on 5.3, but this is almost insignificant though and the database performance comes from elsewhere as we know.
MySQL released 5.4.1 the other day with "scalability improvements" -- how badly were they needed?

http://www.ramoonus.nl/2009/06/30/mysql-5-4-1-released/
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Scalability

Post by califdon »

This is an interesting topic (about which my knowledge is meager). An acquaintance of mine is a real expert, though, and is co-founder of a small company that specializes in scaling solutions. As a former MySQL AB employee, then the chief MySQL guru at Yahoo!, he's the most knowledgeable guy I know on this topic. http://jcole.us/blog/about-me/
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Scalability

Post by Christopher »

So perhaps we can have a discussion of the different options. There are Master:Slave, Master:Master, Replication Rings, Clusters, etc., etc. What are the features to each provide, and downsides do they present. And what do PHP database libraries need to support this stuff?
(#10850)
Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Re: Scalability

Post by Theory? »

What I'm really trying to wrap my head around is if its better to have multiple databases or to have one big database server that is both well structured and leveraged by a load balancing lightweight web server. The overall architecture is where I'm stuck.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Scalability

Post by Eran »

It's very dependent on the particular needs of a specific application. One machine is easier to maintain than a replication chain / cluster but ultimately it will saturate - meaning it will not scale beyond a certain point. At that point you will have to separate the database to separate machines.

Whether this is a decision to be taken before even approaching such a saturation point is highly debatable. Personally I would recommend going with the simplest and most maintainable approach first, allowing for enough room to improve later when (if) the need arises.

I did some research on database scaling solution some time ago, the results of which are posted on stackoverflow if you are interested - http://stackoverflow.com/questions/1899 ... clustering
Post Reply