the Tomcat cluster configuration scheme can be broadly divided into two configurations: shared session and different session types. Of course, there is a need for the upper layer to have a certain structure for consistent routing if not shared. What is consistent routing, simply speaking, is how you walk, this time or how to go, the way to achieve a lot of ways, such as directly according to Nginx source or destination IP for the corresponding HASH,DNS geographical division, etc., as long as the last and the next step into the "same river" can be. On the other hand, if you do not share the need to have a mechanism to share the session mechanism, when sharing is generally divided into two, find a third-party storage session or backup (or routing) session with each other. Third-party storage requirements are certainly fast, preferably the network is also better, so in this case generally choose Memory storage unit to complete, you can rule memcached or Redis, if you are concerned about the occasional failure of the session, it is recommended to use the latter. The second option is to have Tomcat know about each other's existence, or to have all of the session content. At this point, the above scenarios can be divided into five cases, the following conditions in the scalability, fault tolerance, weight support, less redundancy, the characteristics of randomness (+ relatively strong, weak) wherein, extensibility refers to the rapid deployment of new nodes need to do the configuration work; fault tolerance refers to the extent to which the global impact occurs when errors occur. Weight support refers to whether the dynamic allocation of weights between different nodes is supported; less redundancy refers to the degree of redundancy of session information; Randomness refers to the support of random access between different nodes.
Storage Scenarios |
Scalability |
Fault tolerance |
Weight support |
Less redundancy |
Randomness |
Consistent routing (DNS, address demarcation) |
+++ |
++ |
- |
+++ |
- |
Consistent routing (consistent hash) |
+++ |
++ |
+ |
+++ |
+ |
Third-party storage session |
+++ |
+ |
+++ |
+++ |
+++ |
Session merge Replication |
- |
+++ |
+++ |
--- |
++ |
Session Routing |
+ |
+ |
++ |
++ |
+ |
In this case, third-party storage is more dominant. The above comparison is a personal point of view, please exchange comments.
Tomcat Cluster configuration scenario comparison