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:
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.
Well, I am not really experienced at building AWS structures yet, but I will try to help.
1) You cannot share EBS volumes through EC2 instances, you will have to use a web-service or RDS to this scenario... Maybe it will be easier to pay a little more for a better instance while you work on the changes, also, Load Balancer adds a little more expences on your system, use aws calculator to check if it worth.
2) For the files I suggest you to use S3, api is really simple, no tricks, good speed and a lot cheaper than storing images on EBS, just save the link on database and you are good, access from anywhere.
3) As I mentioned on the first answear, you cannot share the EBS volume, so, you will need two equals instances.
Also, take a look at this option: http://aws.amazon.com/pt/elasticbeanstalk/ It is a really simple way to start anything at aws.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With