My current scenario is that I have a Java EE application built on Struts 2.0 and running on tomcat + mysql server. The app is currently hosted on Virtual Private Server with 2GB RAM and 60GB disk. However the application usage increases by 10 to 20 times during the peak hours resulting in crashing of Tomcat and MySQL server.
I started looking for alternatives and found Amazon's EC2 as the best match. I have successfully set-up the free tier Micro instance of RHEL AMI and installed Tomcat + MySQL on the machine. I also read about EBS, Load Balancers, Auto Scale, Cloud Watch and related stuffs on Amazon website.
This is my primary objective which I want to achieve via AWS:
- Set up two EC2 instance on Amazon (Primary and Secondary)
- The secondary instance will be inactive during most of the day
- During the peak hours, the secondary instance should wake up automatically
- The Load Balancer will then start routing traffic to both the server depending upon availability
- After the traffic reduces, the secondary server should be de-activated automatically
I have the following dumb questions :)
How will MySQL data be shared between both the EC2 instance? Can I install MySQL on an EBS volume and mount this volume on both the EC2 instance, at the same time? Will this solve my existing MySQL problem of : Too many connections, which I get alot on my current VPS during peak hours?
How do I share uploaded files and images on both the EC2 instance? Will I have to store these files on the external EBS volume (outside my Tomcat WebApps Directory)?
Can I keep my complete project folder in the External EBS volume and have both the EC2 tomcat instance do a virtual mapping? Kindly let me know the pros and cons of it.
Also, some good tutorials on Clustering tomcat on EC2, session management, AWS auto scaling and load balancers will be of great help.