Re:Ask HN: Best practices for small web app in the cloud
by imp on Wednesday September 29, 2010 @10:43AM
(#1739549)
> I am looking at running two instances to separate the db and the web server. Is it critical to set up some kind of VPN/tunnel for them to talk, or just set the security settings based on IP address?
For backups, you should set up your database on an EBS volume and you can then run a cron script to take snapshots on a regular basis. Could be hourly even, because it freezes the database instantly and allows it to continue operating with minimal delay. I have a 2 GB database that I snapshot in under a second. This is the ultimate article on using MySQL on EC2: http://developer.amazonwebservices.com/connect/entry.jspa?ex...
I did a two server setup on Amazon, and it was nice because you can scale up the web and db servers separately, depending on where the load is. It's also a lot easier to debug system related issues because you've already narrowed down half the possible search space. Make sure CloudWatch is enabled, because that's invaluable. I scaled up to an extra large web server and extra large high-cpu database server, and that handled up to roughly 600 req/sec for my PHP app.
For security, I'm not an expert so I can't give much advice here, but EC2 at least does a good job of restricting access on all ports by default. When you set up your servers, make sure to punch a hole in your security group for port 3306 so that MySQL can connect between the two.
From my experience, you don't need a VPN. Something like what this article mentions should work just fine: http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-...
For backups, you should set up your database on an EBS volume and you can then run a cron script to take snapshots on a regular basis. Could be hourly even, because it freezes the database instantly and allows it to continue operating with minimal delay. I have a 2 GB database that I snapshot in under a second. This is the ultimate article on using MySQL on EC2: http://developer.amazonwebservices.com/connect/entry.jspa?ex...
I did a two server setup on Amazon, and it was nice because you can scale up the web and db servers separately, depending on where the load is. It's also a lot easier to debug system related issues because you've already narrowed down half the possible search space. Make sure CloudWatch is enabled, because that's invaluable. I scaled up to an extra large web server and extra large high-cpu database server, and that handled up to roughly 600 req/sec for my PHP app.
For security, I'm not an expert so I can't give much advice here, but EC2 at least does a good job of restricting access on all ports by default. When you set up your servers, make sure to punch a hole in your security group for port 3306 so that MySQL can connect between the two.