Handling the maximum number of connections for redis/mysql

Fault In the high concurrency environment of stress measurement, the redis/mysql server cannot be connected, and the application program reports an error and cannot obtain the connection, etc.

Analyze the maximum number of connections maxclients set by default on the redis server is 10000 Use the redis-cli command line: info clients to view the current number of redis connections config get maxclients You can query the maximum number of connections allowed by redis

mysql默认最大连接max_connections是100
      查看 my.cnf 文件

Linux TCP默认连接 1024,最大连接数为 65536
```shell
    [root@HA ~]# ulimit -n  
    1024  
```

**Processing** TCP default modification For communication handlers that want to support a higher number of TCP concurrent connections, it is necessary to modify Linux's soft limit and hard limit on the number of files opened by the current user's process at the same time. . The soft limit means that Linux further limits the number of files that users can open at the same time within the range that the current system can bear; the hard limit is the maximum number of files that the system can open at the same time calculated based on the system hardware resource status (mainly system memory). Usually the soft limit is less than or equal to the hard limit. (Specific modification command processing) [ https://blog.csdn.net/linyu19872008/article/details/19154383 ] https://blog.csdn.net/educast/article/details/22820045

redis和mysql最大连接数修改
    ```shell
    修改最大连接数配置,默认10000,可以在redis.conf配置文件中修改
    # maxclients 10000
    ##(1.2)启动redis.service服务时加参数--maxclients 100000来设置最大连接数限制
    redis-server --maxclients 100000 -f /etc/redis.conf
    ##命令行查看 & 修改稿redis最大连接数
        127.0.0.1:6379> CONFIG GET maxclients
        ##1) "maxclients"
        ##2) "10000"
        127.0.0.1:6379>
    ```

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112463&siteId=291194637