Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 206695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:40:08+00:00 2026-05-11T17:40:08+00:00

There are load balanced tomcat web servers. Every request could be served by different

  • 0

There are load balanced tomcat web servers. Every request could be served by different tomcat server.

How could we take care of this while writing code for the j2ee (struts) based web application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:40:09+00:00Added an answer on May 11, 2026 at 5:40 pm

    First of all, you’ll want to set up your load balancer for session affinity/sticky sessions, so that it continues forwarding all requests to the same Tomcat (as long as it is up) based on JSESSIONID.

    The Tomcat clustering doc states two important requirements for your application to successfully have it’s sessions replicated:

    • All your session attributes must implement java.io.Serializable
    • Make sure your web.xml has the <distributable/> element or set at your <Context distributable="true" />

    If you start putting Objects into Session which don’t implement Serializable (or which have properties/fields that don’t implement Serializable), then you’re going to have problems.

    (Actually these points all apply regardless of which servlet container you are using, I believe.)

    Update: To address some of the questions in the comments about why use sticky sessions when you are balancing the load between multiple servers, I think it’s easiest to explain this with an example.

    First of all, this only really matters if your application keeps some sort of data in-session, which may not be every single application (although it’s probably most). If you don’t keep data in-session then you probably won’t care about any of this and you can just stop reading here.

    Having an environment where you keep data in session but you do not have sticky session would open up a world of headaches.

    Let’s say first.jsp updates some value in a particular session attribute, and second.jsp happens to read this same session attribute. You can set up Tomcat to replicate session data to all servers in the cluster, but this replication does not occur instantly. What if the initial request for first.jsp is handled by server1 and one nanosecond after it completes, the same visitor makes a request to second.jsp, which in your non-sticky environment gets handled by server2. Since replication is not instantaneous, do you have any way of knowing if you are reading the most up-to-date session data? Do you have to add some sort of logic to synchronize your reads across the cluster? This would become giant pain.

    Setting up session affinity/sticky sessions removes this headache; by having all requests from the same client server by the same node, you don’t have to worry about “is this node up to date by the time it handles the request?” When the node fails, the client can still failover to another node in the cluster, which has a copy of it’s session data, but with sticky sessions this becomes the rare case and not the norm.

    There is another reason to want sticky sessions: load between the nodes in the cluster. If a request in a session could be handled by any node, then that would imply that you have all-to-all replication set up in the cluster (meaning the session data of node1 is replcated to node2, node3, …, node N, the session data of node2 is replicated to node1, node3, … none N, etc). All-to-all session replication can become bandwidth and resource intensive when the cluster gets larger, because each addition to the cluster means yet another node that needs to communicate with every other single node in the cluster.

    An alternative to this is have a node’s data replicated to only a few “buddies” in the cluster, so that in case the node fails it’s data is available elsewhere but without every single node having to have a copy. In this scenario, you would configure the cluster so that node1 has it’s data replicated to nodes 2 and 3, node 2 has it’s data replicated to nodes 3 and 4, etc., forming a chain. In this scenario, adding additional nodes to the cluster does not cause the amount of communication between nodes to increase rapidly as it does in an all-to-all scheme.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

We have recently migrated a large, high demand web application to Tomcat 5.5 from
We have a website that runs on two load balanced servers. We use the
I have an IIS7 web application which primarily serves web service requests. As part
Background Info: File Replication is Lame Currently, we have a massive, high-traffic ASP.NET web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.