I assume we are talking about web apps built on Jakarta Servlet technology.
Your web app takes up memory on the web container at runtime. The more simultaneous users, the more memory is taken. To alleviate pressure on memory, some web containers invoke a feature whereby the less-active user sessions are written out to disk.
Also, some web containers do this when shutting down. Current sessions still running at shutdown are saved to disk, and automatically reconstituted when the server launches again.
Yet another scenario is load-balancing where multiple web containers working in tandem may relocate some sessions from any over-burdened server to any underutilized server. This transfer occurs on-the-fly during runtime.
In all these cases, the objects of your web app classes must support Serializable
so that they may be written to storage or communicated over the local network.
In some complicated apps, making all your objects serializable may not be feasible. In that case you may choose to disable those three features I discussed above. Then you would make sure to run your web app on a deployment server that has more than enough cores and more than enough memory to handle the peak number of users your web app will encounter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…