DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006

    Tip: HttpSession replication in a clustered environment.

    Session replication is the term that is used when your current service state is being replicated across multiple application instances. Session replication occurs when we replicate the information (ie session attributes) that are stored in your HttpSession. The container propagates the changes only when you call the setAttribute() method. So mutating the objects in a session and then by-passing the setAttribute(..) will not replicate the state change.

    Example If you have an ArrayList in the session representing shopping cart objects and if you just call getAttribute() to retrieve the ArrayList and then add or change something without calling the setAttribute() then the container may not know that you have added or changed something in the ArrayList. So the session will not be replicated.

    -- By Author of the book "Java/J2EE Job Interview Companion" at http://www.lulu.com/java-success

  2. #2
    Join Date
    Jan 2006

    Best practices: Servlet best practices for scalability

    The clustering promotes high availability and scalability. The considerations for servlet clustering are:

    --Objects stored in a session should be serializable to support in-memory replication of sessions. Also consider the overhead of serializing very large objects. Test the performance to make sure it is acceptable.

    -- Design for idempotence. Failure of a request or impatient users clicking again can result in duplicate requests being submitted. So the Servlets should be able to tolerate duplicate requests.

    -- Avoid using instance and static variables in read and write mode because different instances may exist on different JVMs. Any state should be held in an external resource such as a database.

    -- Avoid storing values in a ServletContext. A ServletContext is not serializable and also the different instances may exist in different JVMs.

    -- Avoid using java.io.* because the files may not exist on all backend machines. Instead use getResourceAsStream().

    -- By Author of the book "Java/J2EE Job Interview Companion" at http://www.lulu.com/java-success 50% off until next 200 copies are sold.

Similar Threads

  1. Clustered Index vs Non-clustered
    By Michael Tzoanos in forum Database
    Replies: 5
    Last Post: 08-09-2002, 01:07 PM
  2. When to use Clustered Indexes?
    By Paul Moss in forum Database
    Replies: 2
    Last Post: 04-26-2002, 10:40 AM
  3. Replication issues
    By Claire in forum Database
    Replies: 0
    Last Post: 02-08-2001, 12:06 AM
  4. sql server agent job step: replication
    By wrench wrench in forum Database
    Replies: 0
    Last Post: 07-04-2000, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.