Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

economical way of scaling a php+mysql website

My partner and I are trying to start a website hosted in cloud. It has pretty heavy ajax traffic and the backend handles money transactions so we need ACID in some of the DB tables.

Currently everything is running off a single server. Some of the AJAX traffic are cached in text files.

Question:

  1. What's the best way to scale the database server? I thought about moving mysql to separate instances and do master-master duplication. However this seems tough and I heard I might lose ACID properties even with InnoDB? Is Amazon RDS a good solution?

  2. The web server is relatively stateless except for some custom log files and the ajax cache files. What's a good way to scale to multiple web servers? I guess the custom log files can be moved to a reliable shared file system or DB but not sure what to do about the AJAX cache file coherency across multiple servers. (I dont care about losing /var/log/* if web server dies)

  3. For performance it might be cheaper to go with larger instance with more cores and memory but eventually I would need redundancy so wondering what's the best way to do this cheaply.

thanks

like image 491
Limbeh Avatar asked Dec 07 '25 20:12

Limbeh


1 Answers

take a look at this post. there is plenty of presentations on the net discussing scalability. few things i suggest to keep in mind:

  • plan early for the data sharding [even if you are not going to do it immediately]
  • try using mechanisms like memcached to limit number of queries sent to the database
  • prepare to serve static content from other domain, in the longer run - from ngin-x-alike server and later CDN

redundancy - depends on your needs. is 'read-only' mode acceptable for your site? if so - go with mysql replication + rsync of static files and in case of failover have your site work in that mode till you recover the master node. if you need high availability - then take a look either at drbd replication [at least for mysql] or setup with automated promotion of slave server to become master node.

you might find following interesting:

  • http://yoshinorimatsunobu.blogspot.com/2011/08/mysql-mha-support-for-multi-master.html
  • http://mysqlperformanceblog.com
  • http://highscalability.com
  • http://google.com - search for scalability, lamp, failover... there are tones of case studies and horror stories from the trench lines :-]
like image 177
pQd Avatar answered Dec 09 '25 14:12

pQd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!