0

I need to lower my AWS costs and looking for ways to reduce my AWS usage. I currently have a single java/tomcat webapp which I run multiple EC2 instances of with different configurations. I have siteone.com and sitetwo.com each with their own EC2 instances under the same ElasticBeanstalk environment. These instances are load balanced, (I am thinking of removing Load Balancing for cost), and they both require SSL and connections to an RDS instance. They are both currently in the same VPC. To reduce my costs I need to reduce my instances. How can I go about running multiple tomcat web apps on a single EC2 instance. I am the sole dev on this and could use some direction. thanks!

1

You could run both instances on the same machine. And use mod_proxy from Apache to internally redirect your traffic to the correct web app (transparent for the user).

Thus, you will need to set up one application to listen at localhost:1337 and the other at localhost:1338. You'll also have to change the DNS settings so that both URLs of you web app point that single machines IP address. Apache will then be able to send he traffic to the correct web app by looking at the URL the user provided (webapp1.com or webapp2.com). If it was webapp1.com it will forward the traffic internally to localhost:1337 and in the other case it will send the traffic to localhost:1338

I found this using Google for "EC2 mod_proxy": http://flurdy.com/docs/ec2/apache_tomcat/#twoServers

And (shameless self promotion): http://blog.beardhatcode.be/2015/10/httpd-proxy.html

1
  • Under this infrastructure I wont be using elasticbeanstalk anymore? My understanding is elastic beanstalk creates a single instance per webapp. Instead I'll manually be deploying and configuring my instance. Correct? – brad12s Nov 3 '15 at 21:50
0

What beardhatcode says (though I would prefer Nginx or even HAproxy), plus of course you can consider dropping the RDS instance by having the DB on that same primary instance. Whether or not that's a good idea depends on the specs of the database, but it is an option nonetheless.

1
  • I'll look at the alternatives. Its my understanding that an instance has no persistent memory or am i confusing an elasticbeanstalk instance? – brad12s Nov 3 '15 at 21:51
0

Switching to OpsWorks from Elastic Beanstalk is probably the easiest solution. OpsWorks supports multiple applications per "stack" (which might only be a single instance).

1
  • Unfortunately my time is fairly limited these days. – thexacre Nov 5 '15 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.