The clustering regulates high scalability and availability. The basic considerations for servlet clustering are:
1. Objects opened in a session could be serializable to support in-memory replication of sessions. Also consider the problem of serializing very big objects. Test the performance to make sure it is running.
2. Design for idempotence. Failure of an impatient or a request users clicking again may result in duplicate requests being given. So the Servlets could be relay to tolerate duplicate requests.
3. Avoid using static and instance variables in write and read mode because different instances can exist on different JVMs or on different operating system. Any state could be held in an external instance such as a database.
4. Avoid sending values in a ServletContext. It is not serializable and also the different resources may exist in different JVMs.
5. Avoid using java.io.* because the files cannot exist on all backend machines #question..