nginx common interview questions

Question 1: Nginx is used to doing?

Nginx is a high-performance HTTP server and reverse proxy, the basic movement and load balancing is used after separation of the front end server cluster.

That is, the proxy server load balancing requests received equalized distributed to the server,

 

Question 2: load balancing principle

 

Question 3: Several common way load balancing? Several strategies

1, the polling (default)

2, weight (weight), which specifies the probability of the polling, and the access rate is proportional to the weight, performance for unevenness backend server

Happening.

upstream backserver {

server 192.168.0.14 weight=3;

server 192.168.0.15 weight=7;

}

The higher the weight, the greater the probability of being accessed in the above example, 30%, 70%, respectively.

But there is a problem that is described above, in the load balancing system, if the user is logged on a server, the user requests a second time, because we are load-balancing system, every request will be relocated to the server cluster one, then the user has logged one server and then relocated to another server, their login information will be lost, this is clearly inappropriate.

3, ip_hash: assign each request by hash result Access ip so that each visitor to access a fixed back-end server, can solve the problem of session.

4、url_hash:

5, fair (third party): according to the response time of the allocation request to the backend server, a short response time priority allocation.

Question 4: the session is not synchronized how to do (because Nginx default polling method is to have this problem)?

We can use ip_hash instructions to solve this problem, if the customer has visited a server, when the user accesses again, the request is through a hashing algorithm, to automatically locate the server. That is fixed every visitor to access a back-end server that can resolve session problems.

Other way: that is to use spring_session + redis, the session into the cache to achieve shared session

Guess you like

Origin www.cnblogs.com/wuzm/p/11891031.html