4

My basic question is: How to start building a web application that could grow fast?

A little background: A customer of me is asking for an offer for a web application. I can not go into details but it's an e-commerce and crowd funding kind of thing. So he wants to spend some money and expects a site that can grow unlimited.

I plan to build it with Zend Framework 2 and MySql. My problem is that I have no experience with large scale web apps. I read everywhere: No problem, just start the project and if it grows to large then you can react on it and add caching, clustering etc.

But is this really true, or do I have to add some scalability mechanisms from the start? Cloud servers (Amazon EC2) for example have a different approach for the file system. Is it possible to switch later? Or what about load balancing? I get problems with session handling, or not? And what about MySql? Or better start directly with a NoSql approach?

So my current plan is:

  • Step 1: Build the web application normally with ZF2 and MySql.
  • Step 2: Add caching like memcache and opcode
  • Step 3: MySql cluster or NoSql or load balancing or cloud server??

UPDATE:

Ok, I know that my question is a little too broad. So I try to track it down to a few specific questions:

  • Better start directly with a cloud server?
  • Can a cloud server grow unlimited?
bitWorking
  • 12,485
  • 1
  • 32
  • 38
  • 1
    ever customer expects the site to grow to become the next facebook - you need to realisticly scope the demand and plan accordingly. –  Sep 13 '14 at 03:08

2 Answers2

2

Scaling is a complicated matter and different projects have different needs. I recently read a good book about scaling PHP applications. Maybe this can help you: https://leanpub.com/scalingphp

Some tips from the book

  • Load balancer for incoming requests
  • 1 Mysql master server for writes and x mysql slave servers for reads (if the master goes down a salve server can be promoted
  • Use a session storage I think the book recommended Reddis (not sure, it's a few weeks back)
  • Run Nginx instead of Apache

And on a personal note:

  • It's maybe about taste but I would recommend Laravel as a PHP Framework, it's lighter than ZF and (again taste..) more elegant.

For now I don't recall more from the book, but if you can't get enough information please contact me by e-mail and I will look it up.

Do I have to concern about scaling from the very start or is it easy to add these technologies like load balancing and session storage later?

What I Learned from the book is that in their case (Twitpic) the scaling started after the project became to big and experienced a lot of down time. In my opinion it's a good thing to think about what scaling steps you want to take. A dedicated (My)SQL server or load balancer can be scaled when your project requires scaling. But when your planning to use a session storage service I would recommend to start using it from the start so you don't have to rewrite code at the moment scaling up is required. Also some session storage services store as much information as possible in the RAM which lowers execution time.

Also when your setting up the server I would say start with Nginx it's uses less resources than Apache.

Barry127
  • 1,212
  • 1
  • 12
  • 23
  • so why not tell me some things that you learned from the book? – bitWorking Sep 13 '14 at 01:55
  • thanks for this information, but it not yet answered my basic question. Do I have to concern about scaling from the very start or is it easy to add these technologies like load balancing and session storage later? About the framework: For my last project I compared almost all PHP frameworks. ZF2 in my eyes has the best code quality and design patterns and it was really a joy to programm with. And it's not slow like everybody thinks.. – bitWorking Sep 13 '14 at 02:19
  • 3
    Static-Classes and Singletons are more elegant? wow... (I agree on lighter and fater on "hello world" apps, but elegancy? not in a million years :D) – Sam Sep 13 '14 at 10:42
2

Your plan:

Step 1: Build the web application normally with ZF2 and MySql.
Step 2: Add caching like memcache and opcode
Step 3: MySql cluster or NoSql or load balancing or cloud server??

Here is my suggestion:

Step 1: Build the web app on CodeIgniter with MySQL (lighter, and faster than ZF2 with MySQL)
Step 2: Do memchace, opcode and don't forget phpfpm 
Step 3: Use Amazon EC2 and use their Load Balancing features to load balance between servers.
unixmiah
  • 3,081
  • 1
  • 12
  • 26
  • thanks, but my question was not about which framework to use. I want to know if I have to add some scaling mechanisms from the very start or is it easy to switch to a cloud server later? – bitWorking Sep 13 '14 at 02:03