Suppose you have a web application and you want to deploy it in Amazon cloud environment with load balance support. The whole process is pretty straight-forward and it generally doesn't take much time.
For this post, I'm using Apache Tomcat web server and I already have a war file from my HelloWorld application.
Here is the Tomcat version I'm using:
I'm using two instances and I have extracted my tomcat zip file into /opt/ folder in each of those two instances. I have also placed HelloWorld.jar file into /opt/apache-tomcat-7.0.39/webapps folder.
Now, I will go to each of those two instances and will start tomcat server. After some minutes (or seconds) I should see my deployed web application is up and running. Which means, I can navigate to these URLs and able to see Log-In screen (initial page of my web app).
All of the above steps which I described so far, have nothing to do with Elastic Load Balancing (ELB). Just like everyone, I just deployed a web app in tomcat server. Before I start showing steps for ELB, I'm assuming your web application is also up and running and you can navigate through URLs separately.
Create Load Balancer
Step#1: On AWS EC2 console, click on the Load Balancer option under "Network & Security" section. If you do not have any ELB yet, you will see an empty list. Click on "Create Load Balancer" button.
Step#2: Write a name of your Load Balancer, this name will be used when it will create a default link. I'm also creating this Load Balancer inside my Virtual Private Cloud (VPC) that's why I'm selecting a specific VPC Id. By default, you might see only port 80 in the listerner configuration list, I have added port 8080 as my web app is running on port 8080. Add appropriate port based on your web application and click "Continue".
Step#3: This screen is dedicated to Health check configuration. Based on configuration, ELB will ping that path with that port to check the health condition and if it fails it will automatically remove your instances from the load balancer.
Since, Log-In is the default screen of my application (welcome page), so I'm using the path of Login screen as my ping path.
Step#4: Choose your Subnet id based on where you want to use your Load Balancer. For my case, subnet-2e961843 is my expected Subnet id.
Step#5: Next screen will ask you to select your security groups. I already have a security group for my VPC and I'm using it here too.
Step#6: In the "Add EC2 Instances" section, add the instances in where you already deployed Tomcat and your web application.
Step#7: This screen is for review purpose. Once you review it you can finally create your load balancer by clicking on the "Create" button.
Step#8: Once you create your balancer, it will redirect you to Load Balancer list and now you will see your newly created load balancer in the list. DNS Name column shows newly created DNS Name for your load balancer and you should be able to navigate it with proper port.
So for my case, I can navigate my load balancer by using:
http://helloworld-353060791.us-east-1.elb.amazonaws.com:8080/HelloWorld/login.jsp
Sticky Session:
Since you are using Tomcat with load balancer, it's pretty obvious that you might want to enable sticky session with session replication in Tomcat. My web application is a Spring MVC application and it uses Spring Security for all type of authorizations and authentications. If I directly go to the Log-In screen of my load balancer and try to authenticate, it might not work. It's expected as Tomcat gets confused when sending request and response in multiple instances. If I enable sticky session I will not face this issue.
You can do it with the help of AWS EC2 console. Open the Load Balancer screen and select your newly created load balancer.
If you look carefully at the port configuration part, you will see "Stickiness: Disabled" for all of your ports. By default, stickiness is disabled for all the ports you select for load balancer. Now click on the "edit" button of the port on where you want to enable stickiness. For my case, it will be port 8080. Once you click on the "edit" button, it will ask you how you want to enable session stickiness. You can either choose Load Balancer Generated Cookie Stickiness or Application Generated Cookie Stickiness. For my simple application, I have selected "Load Balancer Generated Cookie Stickiness" and I entered 86400 as my cookie expiration period which is a day in seconds.
After you enable it, you should be able to test your session stickiness. For my case, now I'm able to successfully authenticate to my application.
Some considerations: Sometimes you might see your load balancer is down or the link is not working or shows no page. In that case, best way to quickly test is to check each of the instance where tomcat is running and check whether you can access them individually (e.g. http://ip.address.instance-1:8080/HelloWorld/login.jsp). If you find that each of the instance is up and running, you can try removing them from your load balancer and add them again. Remember, "Status" section under "Description" tab of your load balancer does not get updated instantly. It takes some time and it waits for the result of the next health check. So wait few minutes until you see "Status: N of N instances in service".
.
That's pretty much it! This is the very basic AWS Load Balancer example with minimum configuration of Tomcat + Session Stickiness. Once its working for you, you can try other options (highly encouraged) and see how it works for you.
Note: For privacy purpose, I had to modify several lines on this post from my original post. So if you find something is not working or facing any issues, please do not hesitate to contact me :)
Now, I will go to each of those two instances and will start tomcat server. After some minutes (or seconds) I should see my deployed web application is up and running. Which means, I can navigate to these URLs and able to see Log-In screen (initial page of my web app).
- http://ip.address.instance-1:8080/HelloWorld/login.jsp
- http://ip.address.instance-2:8080/HelloWorld/login.jsp
All of the above steps which I described so far, have nothing to do with Elastic Load Balancing (ELB). Just like everyone, I just deployed a web app in tomcat server. Before I start showing steps for ELB, I'm assuming your web application is also up and running and you can navigate through URLs separately.
Create Load Balancer
Step#1: On AWS EC2 console, click on the Load Balancer option under "Network & Security" section. If you do not have any ELB yet, you will see an empty list. Click on "Create Load Balancer" button.
Step#2: Write a name of your Load Balancer, this name will be used when it will create a default link. I'm also creating this Load Balancer inside my Virtual Private Cloud (VPC) that's why I'm selecting a specific VPC Id. By default, you might see only port 80 in the listerner configuration list, I have added port 8080 as my web app is running on port 8080. Add appropriate port based on your web application and click "Continue".
Step#3: This screen is dedicated to Health check configuration. Based on configuration, ELB will ping that path with that port to check the health condition and if it fails it will automatically remove your instances from the load balancer.
Since, Log-In is the default screen of my application (welcome page), so I'm using the path of Login screen as my ping path.
Step#4: Choose your Subnet id based on where you want to use your Load Balancer. For my case, subnet-2e961843 is my expected Subnet id.
Step#5: Next screen will ask you to select your security groups. I already have a security group for my VPC and I'm using it here too.
Step#6: In the "Add EC2 Instances" section, add the instances in where you already deployed Tomcat and your web application.
Step#7: This screen is for review purpose. Once you review it you can finally create your load balancer by clicking on the "Create" button.
Step#8: Once you create your balancer, it will redirect you to Load Balancer list and now you will see your newly created load balancer in the list. DNS Name column shows newly created DNS Name for your load balancer and you should be able to navigate it with proper port.
So for my case, I can navigate my load balancer by using:
http://helloworld-353060791.us-east-1.elb.amazonaws.com:8080/HelloWorld/login.jsp
Sticky Session:
Since you are using Tomcat with load balancer, it's pretty obvious that you might want to enable sticky session with session replication in Tomcat. My web application is a Spring MVC application and it uses Spring Security for all type of authorizations and authentications. If I directly go to the Log-In screen of my load balancer and try to authenticate, it might not work. It's expected as Tomcat gets confused when sending request and response in multiple instances. If I enable sticky session I will not face this issue.
You can do it with the help of AWS EC2 console. Open the Load Balancer screen and select your newly created load balancer.
If you look carefully at the port configuration part, you will see "Stickiness: Disabled" for all of your ports. By default, stickiness is disabled for all the ports you select for load balancer. Now click on the "edit" button of the port on where you want to enable stickiness. For my case, it will be port 8080. Once you click on the "edit" button, it will ask you how you want to enable session stickiness. You can either choose Load Balancer Generated Cookie Stickiness or Application Generated Cookie Stickiness. For my simple application, I have selected "Load Balancer Generated Cookie Stickiness" and I entered 86400 as my cookie expiration period which is a day in seconds.
After you enable it, you should be able to test your session stickiness. For my case, now I'm able to successfully authenticate to my application.
Some considerations: Sometimes you might see your load balancer is down or the link is not working or shows no page. In that case, best way to quickly test is to check each of the instance where tomcat is running and check whether you can access them individually (e.g. http://ip.address.instance-1:8080/HelloWorld/login.jsp). If you find that each of the instance is up and running, you can try removing them from your load balancer and add them again. Remember, "Status" section under "Description" tab of your load balancer does not get updated instantly. It takes some time and it waits for the result of the next health check. So wait few minutes until you see "Status: N of N instances in service".
.
That's pretty much it! This is the very basic AWS Load Balancer example with minimum configuration of Tomcat + Session Stickiness. Once its working for you, you can try other options (highly encouraged) and see how it works for you.
Note: For privacy purpose, I had to modify several lines on this post from my original post. So if you find something is not working or facing any issues, please do not hesitate to contact me :)
Thank you for sharing the information here. Its much informative and really i got some valid information. You had posted the amazing article.
ReplyDeleteHadoop Training in Chennai
Great Article android based projects
DeleteJava Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai
Thank you for sharing the information here. Its much informative and really i got some valid information. You had posted the amazing article.
ReplyDeleteAWS training in chennai
Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
ReplyDeleteBE Project Center in Chennai | MBA Project Center in Chennai | ME Project Center in Chennai | Projects Center in Velachery
Hi There,.
ReplyDeleteThanks for the info and the steps.
My Concern is the SSL on the Load balancer and redirection rules how I should do,
Where all the http request should be redirected to https only.
How can I achieve it, Would be grateful if you can help,.
Thanks
Sam
Super !! Very Nice Article I have got happy to read this article. Thanks for shared this article.
ReplyDeletegreat
ReplyDeleteGood blog..Thanks for sharing such a wonderful article.
ReplyDeleteCloud Computing Project Center in Chennai | IEEE Cloud Computing Projects in Velachery
ReplyDeleteBest Mobility ServicesVery good article. this bolg article are good and keep sharing more article.
ReplyDeleteVery nice information and explanation is good. Thanks for sharing. keep on updating such a nice information.
Austere Technologies |Internet Of Things
Very good informative article. Thanks for sharing such nice article, keep on up dating such good articles.
ReplyDeleteIOT services | Inernet of Things Services | Austere Technologies
VERY INFORMATIVE BLOG. KEEP SHARING SUCH A GOOD ARTICLES.
ReplyDeleteBest Cloud Services | Austere Technologies
Very good informative article. Thanks for sharing such nice article, keep on up dating such good articles.
ReplyDeleteBest Digital Transformation Services | Austere Technology Solutions
This is really great informative blog. Keep sharing.
ReplyDeleteBest Application Quality Management Services | Austere Technologies
Great article, really very helpful content you made. Thank you, keep sharing.
ReplyDeleteBest Cloud Solutions | Austere Technologies
Needed to compose one little word yet thanks for the suggestions that you are contributed here, would like to read this blog regularly to get more important updates...
ReplyDeleteBest Online Software Training Institute | Java Training
wow...nice blog, very helpful information. Thanks for sharing.
ReplyDeleteBest Mobility Services | Austere Technology
It is very interesting to learn from to easy understood. Thank you for giving information. Please let us know and more information get post to link. salesforce admin training in hyderabad
ReplyDeleteVERY INFORMATIVE BLOG. KEEP SHARING SUCH A GOOD ARTICLES.
ReplyDeleteBest Commerce College in Hyderabad | Avinash College of Commerce
Hello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
ReplyDeletebigdata training institute in chennai
Thank you for sharing this valuable information. But get out of this busy life and find some peace with a beautiful trip book Best Andaman Tour Package
ReplyDeleteVERY INFORMATIVE BLOG. THANK YOU.
ReplyDeleteBest junior college in Hyderabad | Avinash College of commerce
Great information. Thanks for sharing.
ReplyDeleteBest junior college in Hyderabad | Avinash College of commerce
Good information.
ReplyDeletechartered accountant coaching in Hyderabad | Avinash College of commerce
Good information.
ReplyDeletechartered accountant coaching in Hyderabad | Avinash College of commerce
Good information.
ReplyDeleteB.com Integrated Courses | Avinash College of commerce
Really great blog, it's very helpful and has great knowledgeable information.
ReplyDeleteBest Blockchain services | Massil Technologies
Hi Thanks for the nice information its very useful to read your blog. We provide best Block Chain Services
ReplyDeleteHi Thanks for the nice information its very useful to read your blog. We provide best Finance Training in Hyderabad
ReplyDeleteHi Thanks for the nice information its very useful to read your blog. We provide best Association Of Chartered Certified Accountants
ReplyDeleteHi Thanks for the nice information its very useful to read your blog. We provide best Certified Financial Analyst
ReplyDeleteThank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book ANDAMAN TOUR PACKAGE@14599/
ReplyDeleteHi Thanks for the nice information its very useful to read your blog. We provide best Massil Technologies
ReplyDeleteHi Thanks for the nice information its very useful to read your blog. We provide best Find All Isfs Courses
ReplyDeleteBest informative blog. Thank you.
ReplyDeletecima courses in hyderabad | ISFS
Best informative blog. Thank you.
ReplyDeletecima courses in hyderabad | ISFS
Excellent informative blog, keep for sharing.
ReplyDeleteBest System Integration services | Massil Technologies
Thanks for sharing this pretty post, it was good and helpful.
ReplyDeleteAWS Training in Chennai
AWS course in Chennai
AWS Certification in Chennai
DevOps Training in Chennai
DevOps course in Chennai
R Training in Chennai
Thanks for sharing this tips admin, really helpful to me.
ReplyDeleteAWS Training in Chennai
AWS course in Chennai
AWS Certification in Chennai
DevOps Training in Chennai
DevOps course in Chennai
R Programming Training in Chennai
This is an excellent post that is being shared. Kindly do share more post in this sorts.
ReplyDeleteBest English Speaking Course in Mumbai
English Classes in Mumbai
Best Spoken English Classes in Mumbai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
English Speaking Institute in Mumbai
Best English Speaking Classes in Mumbai
You have provided a nice article, Thank you very much for this one. And I hope this will be useful for many people. And I am waiting for your next post keep on updating these kinds of knowledgeable things.
ReplyDeleteCloud Computing Courses in Chennai
Hadoop Training in Chennai
Digital Marketing Course in Chennai
Selenium Training in Chennai
JAVA Training in Chennai
German Classes in chennai
PHP Training in Chennai
PHP Training in Velachery
Great casino, ever slot machine games online you can safely put the top ten, with the new year already playing. At first I didn’t enter the topic as it is not hung with all sorts of bells and whistles I used to, but over time you realize that only good gaming games, bonuses and timely payments are needed in the casino, everything else interferes and distracts
ReplyDeleteThe given information was excellent and useful. This is one of the excellent blog, I have come across. Do share more.
ReplyDeleteAWS Training in Chennai
AWS course in Chennai
DevOps certification in Chennai
DevOps Training in Chennai
Data Science Course in Chennai
Data Science Training in Chennai
AWS Training in Velachery
AWS Training in Tambaram
As always,great information to read and read again.Definitely will save this post and refer to often.Thanks for the great advice!
ReplyDeleteAuthorized iphone service center in Chennai | iphone service center in chennai | Mobile service center in chennai | Authorized iphone service center in Chennai | iphone service center in chennai | Authorized iphone service center in Chennai | Battery replacement
It is very good and very informative. There is a useful information in it.Thanks for posting...
ReplyDeletehttps://www.apponix.com/Java-Institute/Java-Training-Institute-in-Bangalore.html
This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information regarding Microsoft Azure which is latest and newest,
ReplyDeleteRegards,
Ramya
Azure Training in Chennai
Azure Training Center in Chennai
Best Azure Training in Chennai
Azure Devops Training in Chenna
Azure Training Institute in Chennai
Azure Training in Chennai OMR
Azure Training in Chennai Velachery
Azure Online Training
Azure Training in Credo Systemz
DevOps Training in Credo Systemz
One of the best content i have found on internet for Data Science training in Chennai .Every point for Data Science training in Chennai is explained in so detail,So its very easy to catch the content for Data Science training in Chennai .keep sharing more contents for Trending Technologies and also updating this content for Data Science and keep helping others.
ReplyDeleteCheers !
Thanks and regards ,
Data Science course in Velachery
Data Scientists course in chennai
Best Data Science course in chennai
Top data science institute in chennai
Excellent stuff, this is really helpful for beginners and I am glad to visit this page.
ReplyDeleteAWS Training in Chennai
AWS course in Chennai
Cloud Computing Courses in Chennai
Cloud Computing Training in Velachery
VMware Training in Chennai
Vmware Training center in Chennai
DevOps Certification in Chennai
AWS Training in Chennai
AWS course in Chennai
I have read your excellent post. Thanks for sharing
ReplyDeleteaws training in chennai
big data training in chennai
iot training in chennai
data science training in chennai
blockchain training in chennai
rpa training in chennai
security testing training in chennai
The article was up to the point and described the information very effectively. Thanks to blog author for wonderful and informative post.
ReplyDeletewebsite development
Great blog!!! The information was more useful for us... Thanks for sharing with us...
ReplyDeletePython Training in Chennai
Python course in Chennai
Python course in Bangalore
Python Training in Bangalore
Python Online Course
Python Online Training
Phenomenal Blog!!! thanks for your post and awaiting for your new updates...
ReplyDeleteDigital Marketing Course in Chennai
Digital Marketing Training in Chennai
Digital Marketing Courses in Bangalore
Digital Marketing Training in Bangalore
Digital Marketing Course
Digital Marketing Online Course
Cognex is the AWS Training in Chennai. Cognex offer so many courses depends upon the students requriments.
ReplyDeleteThanks for the required information & the things I never imagined, and I would request, write more blog and blog post like that for us. Thank you once again
ReplyDeleteby cognex is the aws training in chennai(visit here)
Great work done by author of this blog. Its an Amazing blogger.
ReplyDeleteby cognex is the AWS Training in Chennai.
ReplyDeleteGood article. I liked to read your article, valuable information.
use of python
most paid programming language
benefits of learning python
hadoop career
java interview questions for experienced
selenium interview questions and answers for experienced
ReplyDeleteTo hire our Call Girls in Mahipalpur you can speak with our call girl representative over the call. It is very easy to get escort service in Aerocity now. Call us now!! They love to make relationships for the night with Indian men and that is why they join our escort agency to provide foreign Call Girls in Delhi. These ladies are referred to as Foreign escorts in Aerocity.
Hi Profile Escorts in Delhi
Russian Call Girls in Gurgaon
Call Girls in Manesar
Russian Escorts in Agra
thanks for sharing this nice information , here is more info about trending cloud computing courses for readers to know AWS Training in Chennai
ReplyDeleteVery informative and helpful. Thank You for sharing the blog. aws training in chennai | aws course in chennai
ReplyDeleteVery informative and helpful. Thank You for sharing the blog. aws training in chennai | aws course in chennai
ReplyDeleteThis is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
ReplyDeleteaws training chennai |
aws training institute in chennai |
aws training center in chennai |
best aws training in chennai |
aws course in chennai
Valuable Information. Its very useful for me. Thank You
ReplyDeleteAWS training in chennai | AWS course in Chennai
Nice article with valuable information. Thanks for sharing.
ReplyDeleteAWS training in chennai | AWS course in Chennai | AWS training and certification
Thank you for this interesting article<a href="https: https://www.credosystemz.com/courses/azure-training/ Azure Training in Chennai</a>
ReplyDeleteExcellent Post! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
ReplyDeleteaws training chennai |
aws course in chennai |
aws certification in chennai |
aws certification cost in chennai |
best aws training in chennai |
aws training institute in chennai |
aws certification training in chennai |
aws training in chennai velachery |
aws training center in chennai |
amazon web services training in chennai |
aws certification course in chennai |
Best software training institute in Chennai.
ReplyDeleteBest Docker training institute in Chennai
power bi training in chennai
android training in chennai
ios training in chennai
Xamarin Training in Chennai
msbi training in chennai
Informatica training in chennai
Nice article with valuable information. Thanks for sharing.
ReplyDeleteAWS Training in Chennai | AWS Training institute in Chennai | AWS Training center in Chennai
I believe there are many more pleasurable opportunities ahead for
ReplyDeleteindividuals that looked at your site.
dot net training center in Chennai
best core java training in Chennai
manual testing training in Chennai
How to get in with Slot Games at the UK Casino
ReplyDeleteSlot games can also be found 먹튀탐정 on the gambling market. This is 텐벳 먹튀 because 포커 online casinos are offering real money prizes 가입시 꽁 머니 환전 to their customers. You 007 카지노 로얄 토렌트 Rating: 4 · 7 votes
Wild West Slot Review & Casinos 2021
ReplyDeleteWild West is 메리트 카지노 주소 a brand new slot machine from Pragmatic Play 제왕카지노 회원가입 that 온카지노 커뮤니티 looks to 토토 분석 사이트 be a fantastic sequel to the popular classic 우리 카지노 계열사 game from Pragmatic.
Needed to compose a very little word to thank you yet again
ReplyDeletefor the nice suggestions you’ve contributed here..
ReplyDelete.
Very nice blog.
ReplyDeleteFold n fly | Classic dart paper airplane | how to make a paper airplane that flies far and straight step by step | windfin | stable paper airplane | nakamura paper airplane | paper airplane templates for distance
ReplyDeleteThanks for this blog. provided great information. All the details are explained clearly with the great explanation.
AWS Training in Chennai
ReplyDeleteThanks for this blog. provided great information. All the details are explained clearly with the great explanation.
AWS Training in Chennai
Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
ReplyDeleteangularjs training in chennai
canlı sex hattı
ReplyDeletejigolo arayan bayanlar
heets
C28A68
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
E8M56
A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
ReplyDeleteCloud Computing Training in Chennai
A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
ReplyDeleteCloud Computing Training in Chennai