views:

329

answers:

3

Hi everybody!

We are in the startup build phase of a new PHP webapp that will be placed onto a cloud server to allow fast and easy up/downscaling when customers will grow or decrease in numbers. Most probably, we will use a PHP framework (Codeigniter) to keep development speed high.

Our next step is to implement features for increased performance (cacheing etc) and choosing which databases to use.

Solutions like memcached and eaccelerator is of course what comes up into our minds at first, but are there even better solutions available out there today?

Is mySQL really yesterdays choice when high performance is in focus?

So, please - share your ideas and thoughts on how to create the basic cornerstones for a high performance webapp!

Thanks!

+3  A: 

I think you should focus on building a good app, and worry about performance once you have a big enough user base that it matters. That isn't to say you should code without performance in mind. However it sounds like you're trying to optimize before you even have any real users. Any performance tuning you do would be theoretical, and not based on what actually happens with your particular application. You'll have to have a lot of users before you can see the usage patterns and the bottle necks that result specifically in your application. Also, if you're really worried that much about performance at this level, using PHP is not the way to go. PHP can be made fast, but compared to other languages which are compiled, it will always be slower. There is no answer. It all depends on what your application is doing. PHP can work fine if most of the server time is spent somewhere else like in the database. MySQL can be fine depending on what you're doing, and what kind of information you are trying to use it for.

Kibbee
Hi Kibbee! Thanks for your reply. What you are saying is completely true, trying to optimize before real users are apparent is like expanding a house before building it.However, no one wants to build their house without the best available foundation. Sorry for the metaphoric approach, but my question is based on which features that are available to choose and use in order to create the best possible foundation on top of PHP when having performance in mind. What is a fast compiled language in your opinion?
Industrial
+2  A: 

Two things you should know:

  1. 8 or 9 out of 10 startups fail; and
  2. Nothing exceptional is required to get you to 1-5 million uniques a month. If and when you get to 5+ million uniques ou will probably have rewritten your application 2-6 times.

So basically don't worry about this "problem" until you have a problem.

Also cloud servers are good for burst usage but the data fees tend to make them a bad choice for constant usage. The typical progression is:

  1. Shared hosting (you may skip this);
  2. VPS (you might skip this too);
  3. Dedicated server; then
  4. Co-location.

As for what tools to use, well that depends entirely on your app. MySQL is a fine choice for most circumstances. An opcode cache like APC or eAccelerator is typically a good idea. Memcache can be useful for certain kinds of applications.

cletus
I would agree with this @Cletus except for some really bad code I saw the other day -- I would say it is easy to not be able to handle 1-5 million uniques if you have some bad coders at the application or data tier. Don't skimp on the programmers.
Hogan
@Hogan: sure you can write bad code in anything but the question isn't so much "how do I write good code?" (which is the subject of a complete education, not a single question) but rather "do I have to do anything special?" to which the answer is "no".
cletus
@Cletus Well, overanalysing details in early stages of a project does often lead, in one way or another, to either failure or that the needs of high performance or scalability never will appear - just like you said. However there's probably more good resources out there than those of which I know, that can improve both speed and performance (in the long run scalability) and to get these implemented as early as possible would in my opinion be awesome.
Industrial
@Cletus Besides the economical part of using VPS as a main hosting supplier, wouldn't you agree that it is really good to be able to up and downscale on demand and in any stage of the business development have bigger costs than necessary?
Industrial
@Industrial cloud services make sense when you need a lot of temporary VMs (eg http://litmusapp.com/ use cloud VMs to create browsers to snapshot pages) or when you have huge burst needs. Most people don't have either problem. Ultimately colocation is where it's at.
cletus
@Industrial the problem with planning for scalability is that what you think will be the problem rarely is. Are there things you should know? Probably but I don't know what you know. What's more important is having a good page design, a good UI, fast loading pages and of course a great product.
cletus
@ Cletus - You're totally right. All those things are essential. However please let me know if there's anything better available out there than an approach including memcached and mySQL.
Industrial
A: 

PHP and "scalable high-performance applications" are not often terms that belong together. PHP is slower than other choices available. While you won't have to worry about scaling your application for a while (as Kibbee points out), if you want to plan for it at this stage I would pick a different stack.

Hogan
-1 Bzzzt, wrong. 4 out of the top 20 sites run PHP. Please stick to the facts rather than religious zeal.
cletus
Just because sites use it does not mean it is the most scalable choice. That was the point of my comment on your answer, if you have a good programmer/team you can solve most problems with any platform. As you pointed out 1-5 mil uniques a month is no problem with a **well built and designed** app on any platform. But the answer is still the same -- if you want "scalable" then some tools are known to not be as fast. I actually do stick to the facts and not religious zeal. A downvote on my answer seems to be this zeal you speak of.
Hogan
-1. You cannot say you stick to the facts without quoting any. "Some tools are known to not be as fast." This is an opinion (albeit widespread), and with some light googling of terms like 'php scalability' you can find thousands of articles, surveys and case studies going back over the past 5 years that show this to simply not be the case, and a lot of recent efforts from a few of the top websites that cletus alluded to have further solidified this (such as Facebook, built using php on a custom LAMP stack with over 100 million unique visitors / mo., now the 2nd globally most popular site).
Kevin
@Kevin : I'm saying the same thing that Kibbee is saying "Also, if you're really worried that much about performance at this level, using PHP is not the way to go. PHP can be made fast, but compared to other languages which are compiled, it will always be slower." but he is not getting down votes... I find that interesting -- of course he said it in the 2nd paragraph so maybe you did not read that far?
Hogan
@Cletus + @Kevin and other close minded : 15 years ago all the top websites used CGI -- does that mean we should all continue to use CGI? Of course not, times change and our understanding of best practices change. PHP is easy, it has been around a long time and is well understood -- that does not make it the best (nor does it make it the worse.) Most often, as I've said on this question a number of times, the performance of a web app is directly related to the skills of the designers and programmers.
Hogan
Facebook, does do a lot of pageviews on PHP. However, as Kevin said, they also had to use a Custom LAMP stack. They rewrote a bunch of PHP to make it faster, because it was just too slow. They had to do a lot of work that wouldn't have been necessary had they used a different stack. However, had they chose another stack, they would have had a whole other set of problems. I think the reason I didn't get downvoted so much is because I had a lot more to my post than PHP is slow.
Kibbee
@Kibbee: Thx for your comment -- exactly my point, they did not bother to read your post to the end. Clearly the answer to this person's question is not - use PHP if you have to scale make a custom PHP stack. A custom PHP stack is not a PHP stack. The original poster's question is "What are today's best approaches to scalable web applications?" I stand by both our answers -- PHP is not today's best approach to scalable web applications. Zealots can continue to down vote me on this, I know that answer to be correct.
Hogan
Hi guys. PHP is what we will use for this project since that is what we have resources to produce right now in our team. To make a switch to Ruby, Erlang, Python or whatever language that is faster and more high-performing than PHP would be interesting to consider in the long run, but I would appreciate if you would stick to the main question right now and that it includes building this app in PHP. Thanks!
Industrial
Feel free to post links to pages or discussions where more information about other languages are available and their pros/cons compared to PHP is available. Thanks!
Industrial
Here's an interesting view on the subject: http://www.ryandoherty.net/2008/07/13/unicorns-and-scalability/
Industrial
@Industrial : Great link! I agree totally. As I've said multiple times the design team is the most important.
Hogan
@Hogan - Let me know if you have any ideas regarding the main subject - what's todays best solutions consist of in order to offer best performance in a PHP app.
Industrial
@Industrial : In any platform you want as modular an architecture as possible. This gives you the ability to fix sub-systems when they are bottle-necks. This is the appeal of SOA and other techniques.
Hogan
@Hogan - Trying to find as much as possible info about it. Do you have any practical examples available online of it?
Industrial
@Industrial : Simple web searches on SOA-Service Oriented Architecture (tends to MS focused), SOC-Separation Of Concerns, MVC-Master View Controler (nice SOC design pattern for webapps), OOP-Object Oriented Programming, Loose Coupling should turn up a number of great resources. A practical example... well stackoverflow uses MVC and you can find a lot about design issues in real world scaling on the blog. Also, enjoy http://highscalability.com/ but remember it is often "sensational" journalism.
Hogan
@Industrial : Also, I respect that you don't want to give away the details of your project, but the super high-level stuff can and should drive the over-all design pattern for the system. Anything you can tell me about it could help in finding good resources.
Hogan
@Hogan - It uses codeigniter and thereby the MVC-pattern. Loose coupling and OOP is interesting, will check it out. Thanks!
Industrial