5

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.

4

1 回答 1

3

好吧,我在构建 AWS 结构方面还没有真正的经验,但我会尽力提供帮助。

1)您不能通过 EC2 实例共享 EBS 卷,您将不得不使用 Web 服务或 RDS 来处理这种情况......也许在您进行更改时为更好的实例支付更多费用会更容易,也, 负载均衡器在您的系统上增加了一些开销,使用 aws 计算器检查它是否值得。

2)对于文件我建议你使用S3,api非常简单,没有技巧,速度好,比在EBS上存储图像便宜很多,只需将链接保存在数据库中就可以了,可以从任何地方访问。

3)正如我在第一个回答中提到的,您不能共享 EBS 卷,因此,您将需要两个 equals 实例。

另外,看看这个选项:http ://aws.amazon.com/pt/elasticbeanstalk/ 这是在 aws 开始任何事情的一种非常简单的方法。

于 2013-08-24T12:47:10.830 回答