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().

ServletContext as an interface is not serializable but finally it depends on the implementaion of ServletContext by the container . Hence if the implementation is serializable it can still be passed across JVMs for clustering .

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.