开发者

LAMP hosting on AWS Cloud - what PHP code to re-write?

I want to host a PHP application on Cloud to take advantage of on-demand scalability. I am afraid if my application were to get featured on Digg/Slashdot/popular blogs (hopefully all of these places) then my site would very likely crash. So, I was looking into A*mazon EC2, RackSpace Cloud Servers etc.* But I am confused by Cloud Architecture. Hosting a PHP application on regular cPanel based shared-hosting is very simple. FTP upload your code to public_html directory and you are done.

But with cloud, we'd have multiple servers. My understanding is that in Cloud, you get some VM space behind some load-balancer. When you need more resources, you simply provision another VM. Load balancer sends request to all available resources. So, how do you deal with these things:

  • Session management/session continuity: Now, one of the obvious thing here is that Cloud-Server-1 is not going to be aware of user-session on Cloud-Server-2. So, how is this managed in cloud based hosting? Would I be required to re-write some PHP code that deals with sessions? (I am thinking of hosting an e-commerce PHP script done in Yii framework)
  • Would the PHP code that deals with session need to be re-written or is there an abstraction layer that handles it? Basically, do I simply FTP upload the application and then some abstraction layer takes care of everything or do I have to re-write some code?

  • Database scaling: When there开发者_开发问答 is heavy load, I think I can configure Amazon EC2 or any cloud-server to automatically provision more servers. And besides, it's probably a good idea to have multiple servers anyway to increase speed and reliability. But I am not sure how that works. I mean, the "data" in the database has to be shared.

So, how are multiple database-servers maintained? If each database is a real-time copy of each other. Then how will it reduce load? I mean, if you do a query on DB1, and then in real-time, this query is also done in DB2 (if not, the data in DB2 would not be same as DB1) then both DB will have same load.

Some Cloud Servers I am considering are:

  1. Amazon EC2
  2. RackSpace Cloud Sites
  3. RackSpace Cloud Servers
  4. PagodaBox (still in BETA and does not allow crons though): http://www.pagodabox.com/
  5. Go Grid scalable website architecture: http://www.gogrid.com/cloud-hosting/cloud-hosting-packages/scalable-website.php (although this is very very expensive. I was hoping to start with a single server to begin with and then automatically provision extra web-servers and/or extra DB-servers to handle load spikes as needed)

Any tips would be appreciated.

Thanks


I talked to tech-support of a hosting company. He didn't seem like a uber-geek but he gave me this advise: create multiple web-servers & multiple DB servers. Here is how:

  • Multiple web servers: he said you should load image of your application on multiple servers. Start-up 1 server initially. If the load is high, start-up the other image. Load balancer would automatically start sending queries to this new instance of your web server.
  • DB Servers: create multiple DB servers. 1 master and several slaves.

He said, you'd need to rewrite some PHP code and do the following:

  1. Session handling: he said modify your PHP code so that sessions are stored in "DB" .

  2. DB related code: Remove all "join" operations. I am not sure if this is even possible to remove ALL join operations. Any tips on how to do this? Is there no way to "scale" while retaining "join" operations?

That's all. Really, is it this it? Or do you think there are other things to take care of as well?

Also, to create multiple DB server instances (master-slave). Write to master only. I would need have at-least two (2) DB servers running at ALL times. If the load isn't high, wouldnt I be paying for extra DB server for no reason?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜