Current location - Quotes Website - Team slogan - How to solve the problem of session consistency of Nginx
How to solve the problem of session consistency of Nginx
Scheme 1: session maintenance module, that is, session maintenance between the client and the back-end server is realized through cookie. Under certain conditions, the same client can be guaranteed to access the same back-end server, which can solve the problem of unavailable and inconsistent sessions.

Scheme 2: session*** sharing (recommended), that is, when the server sends a distribution request to a machine, it will first check whether there is a user's session in the session cache database, and if there is one, it will be taken out, otherwise a new one will be created. So how to solve this conversation? * * * There are two methods: 1 and memcached caching scheme. 2.Redis caching scheme. The following focuses on the problems encountered in the * * * * seminar:

1, memcached caching scheme

The Memcached cache database is dedicated to managing sessions. Memcached caching services can be integrated with tomcat to help tomcat *** enjoy managing sessions.

Install the memory cache:

# yum–y Install memory cache 1 1

Start memcached (the default port is11211):

# service memcached start 1 1

Testing memcached database through telnet

# telnet localhost 1 12 1 1 1 1

test

Set abc 0 0 5

12345

Get abc

quit 1234 1234

Copy the memcached jar package to tomcat's lib, and the download address of the jar package is: Orange function. Tomcat . redis sessions . redis session handler valve "/>

& ltmanager class name = " com . orange function . Tomcat . redis sessions . redis session manager "

host = " 192. 168. 17.4 "

Port ="6379 "

Database ="0 "

maxInactiveInterval = " 60 "/& gt; Seek adoption. Adoption, adoption, adoption