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!
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 (
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
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