In-depth study on Lvs scheduling strategy

  

Lvs basic problem:

In the usage of ipvsadm, many documents are explained for the persistent parameter. -p –persistent [timeout] A persistent service. This option means multiple requests from the same client and will be processed by the same real server. The default value for timeout is 300 seconds.

“From the same customer" How to understand it, whether it is an IP-based client or a browser-based client-based cookie, it should be based on the source address. There is actually a parameter [-M netmask] , which indicates that the source address is matched, for example, -p 900 -M 255.255.255.0 is the same as the network address after the mask is used to request the same template. The 10.1.9.8 and 10.1.9.9 machines simultaneously access the same vs. Just use the same template, that is, to the same rs.

Rr scheduling algorithm is very simple, it only maintains a pointer to the rs loop queue, if vs requests scheduling, rr will make the current pointer rs do For this connection request rs, then after the pointer. It does not care what template.

Even if the setting "quiescent=yes", the scheduler can correctly dispatch the request to the normal node, then the original node The session on the session cannot be copied to the normal node, and it is lost. At this time, the client will prompt for re-login, etc. At this point, the session can be saved to an independent fs, mysql, network storage.

Lvs connection algorithm:

For the configuration of p vs, the system schedules and creates a connection template such as <lt; before establishing a new connection such as <x:1234,y:80> ;x:0,y:0,z:0>, the timeout period of the connection template is p, for example, 900s, and then the available connection is created according to the template, for example, <x:1234, y:80, z:80>, so the data is connected from this. If there is a new request for <x:1235,y:443>, vs will look for a template. If it is found, it will not re-schedule, but create a real connection based on the rs provided by the template<x:1235 , y:443,z:443>, and reset the timeout of the template, that is, reset to 900s.

1. The template is actually a connection, but it is special, ipvsadm -Lcn should be able to See 2. The timeout of the connection is the parameter of p. If the template is reused, the timeout period is reset. If the user's http request does not exceed the timeout period, the user's request is sent to the fixed rs according to the template.

Flow of lvs operation

Package->vs->Find whether a connection already exists 1. Existence exists according to the connection. 2. Does not exist, is a new connection, starts scheduling

If vs is a normal server, execute the scheduling algorithm to select an rs, then create a connection, and then send if vs is a p server (a DR server with the -p –persistent parameter set), then first check to see if A template is available, and if so, a connection is created based on the template and then the package is issued. If no template is available, execute the scheduler to dispatch to an rs and create a template, then create a connection based on the template, and finally send the package.

Thanks to CU qtdszws users for their help, thank you!

Copyright © Windows knowledge All Rights Reserved