Why and how is serialization used in Java web applications?

后端 未结 5 995
名媛妹妹
名媛妹妹 2020-12-30 05:13

I\'ve been working on a Java web application where the framework insists that everything is Serializable. I assume that this isn\'t specific to the framework but to web app

5条回答
  •  囚心锁ツ
    2020-12-30 06:13

    It's not strictly necessary for most apps, but can help performance in two ways:

    • User sessions can be serialized to disk between requests. When the time between requests from the same user is much longer than the time it takes to process a request, this can drastically reduce memory usage of the server and enable you to serve far more users.
    • If you use load balancing to spread requests over multiple servers, you either need to ensure that all requests by the same user are always served by the same machine (which reduces the flexibility of the load balancer) or you need to be able to move session data between servers via serialization.

提交回复
热议问题