nginx + tomcat cluster shared session

1. Common Tomcat clustering solutions:

  1) using ip hash policy nginx is to maintain an IP connection is always on one machine

  Advantages: the prior art can not change the architecture implemented directly scale, easy. But the disadvantages are also obvious, actual production, rarely used in this way

  Disadvantages: a) single server request (load) is not balanced, it is the case of dynamic changes completely dependent on ip hash result b) client ip, can not be served because of possible ip hash is different every time, you can not always remains connected only on the same machine

  2) the use or memcache nosql redis such as database, server implement a cache of session, when the request came, all the tomcat server are unified to the server where the reading session information. This is more commonly used in business a solution.

  

 

2. nginx load balancing configuration, common strategies, scenarios and features

  1) Polling (default)

  Advantages: simple

  Disadvantages: does not consider the processing capacity of each server

 

  2) weight, more use of strategies

  Pros: Consider different for each server processing power, high-performance machines which give the right to which machine weights higher

  

  3)ip hash 

  Advantages: can always access the same server to achieve the same user

  Cons: average is not necessarily based on ip hash

 

  4) url hash (third-party plug-ins need to install plug-ins)

  Advantages: able to access the same server to achieve the same service, which is carried out according to the load url

  Cons: ip hash and the same, according to the average request is not necessarily url hash assignment, requesting frequent requests to the url on the same machine

  5) fair (third-party plug-ins need to install plug-ins)

  Preferentially allocated according to the response time of the backend server allocation request, the response time is short: Characteristics

 

3. Install deployment

   https://blog.51cto.com/zero01/2112989

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/lili-xia/p/12460838.html