Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Analysis on the causes of load imbalance

Shulou Source: shulou.com Published: 2022-06-01 07:10:24 10月03日 Update

First of all, analyze the reasons that may lead to uneven load:

1. Lvs's own persistent10 may lead to uneven load.

2. The setting of scheduling algorithm may lead to, such as rr, wrr, wlc, lc algorithm.

3. Report retention parameters of the backend RS node, such as the keepalive parameter of apache

4. when the number of visitors is relatively small, the phenomenon of imbalance is more obvious.

5. The relationship between the time of the request sent by the user and the size of the resource.

The general direct solution:

Comment out the persistent10 in keepalived, and then restart it; (Huihua keeps using cookies and sesson solutions)

Secondly, we can directly use memcached as the session.save_handler of PHP to solve the sesson sharing problem.

Reprint # Old Boy #

1. Install memcached server software # software package see attachment

Note: memcached uses libevent as the event driver, so install libevent first.

two。 Install memcache client parts

Briefly, see the old boy training related video tutorial or Google search under the installation.

3. The beginning of the real configuration

Modify the configuration file to set the global settings in php.ini:

Web cluster session shared storage settings:

The type and configuration path of session in the default php.ini:

# session.save_handler = files

# session.save_path = "/ tmp"

Modify it to the following configuration:

Session.save_handler = memcache

Session.save_path = "tcp://10.0.0.18:11211"

Tip:

1) 10.0.0.18 11211 is the IP and port of the memcached database cache.

2) the above is suitable for LNMP,LAMP environment.

3) memcached servers can also be scheduled by multiple hash.

4. Using memcached to store session features:

Advantages:

1) the speed of reading and writing is much faster than that of normal files.

2) it can solve the problem of sharing session among multiple servers.

Disadvantages:

1) session data is stored in memory, which is lacking in persistence, but it is not a problem for session data.

2) single point, multiple computers are deployed, and data synchronization is not possible. There is still a problem of sesson loss in allocation through hash algorithm.

5. Solutions for large-scale enterprises:

2) other persistence systems can be used to store sessons, such as redis,ttserver, instead of memcached.

3) High performance and high concurrency scenarios, and the efficiency of cookies is much better than that of session. Therefore, large websites will use cookies to solve the problem of session sharing.

Tags: Data problem configuration algorithm storage service inequality parameter multiple server boy software scheduling equilibrium reason obvious advantage global scenario multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB NVidia Shulou Technology macOS