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?
4

2 回答 2

2

你的计划:

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??

这是我的建议:

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.
于 2014-09-13T01:57:17.907 回答
2

扩展是一件复杂的事情,不同的项目有不同的需求。我最近读了一本关于扩展 PHP 应用程序的好书。也许这可以帮助你:https ://leanpub.com/scalingphp

书中的一些提示

  • 传入请求的负载均衡器
  • 1个用于写入的mysql主服务器和x个用于读取的mysql从服务器(如果主服务器出现故障,可以提升一个从服务器
  • 使用会话存储我认为这本书推荐了 Reddis(不确定,这是几周前的事了)
  • 运行 Nginx 而不是 Apache

并就个人而言:

  • 这可能与品味有关,但我会推荐 Laravel 作为 PHP 框架,它比 ZF 更轻巧并且(再次品味..)更优雅。

现在我不记得更多的书了,但如果你不能得到足够的信息,请通过电子邮件与我联系,我会查一下。

我是否必须从一开始就关注扩展,或者以后添加负载平衡和会话存储等这些技术是否容易?

我从书中学到的是,在他们的案例(Twitpic)中,扩展是在项目变得很大并且经历了很多停机时间之后开始的。在我看来,考虑要采取哪些扩展步骤是一件好事。当您的项目需要扩展时,可以扩展专用的 (My)SQL 服务器或负载均衡器。但是当您计划使用会话存储服务时,我建议您从一开始就开始使用它,这样您就不必在需要扩展时重写代码。此外,一些会话存储服务在 RAM 中存储尽可能多的信息,从而降低执行时间。

另外,当您设置服务器时,我会说从 Nginx 开始,它使用的资源比 Apache 少。

于 2014-09-13T01:53:11.363 回答