Reasonable estimated configuration of JedisPoolConfig

  The first step is to set the initial configuration of

JedisPoolConfig. JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        //Set the maximum number of instances
        jedisPoolConfig.setMaxTotal(500);
        //Control how many jedis instances in idle (idle) state at most in a pool.
        jedisPoolConfig.setMaxIdle(100);
        jedisPoolConfig.setMinIdle(100);
        //Indicates the maximum waiting time when borrowing (introducing) a jedis instance. If the waiting time is exceeded, JedisConnectionException will be thrown directly;
        jedisPoolConfig.setMaxWaitMillis(3 * 1000 );
        // When borrowing a jedis instance, whether to perform the validate operation in advance; if it is true, the obtained jedis instances are all available; 
        jedisPoolConfig.setTestOnBorrow(true);
        // Whether to perform the alidate operation in advance when it is also given to the pool validate operation 
        jedisPoolConfig.setTestOnReturn(true);
        jedisPoolConfig.setTestWhileIdle(true);
        jedisPoolConfig.setMinEvictableIdleTimeMillis(500);
        jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(1000);
        jedisPoolConfig.setTimeBetweenEvictionRunsMillis(1000);
        jedisPoolConfig.setNumTestsPerEvictionRun(100); return new JedisPool(     jedisPoolConfig
        , HOST, PORT, 5000, null, 0);

A web project application of a tomcat container, new url link, internal business implementation: create a new Jedis, call JedisPool, and run this tomcat.
    The third step is to use the jmeter pressure testing tool, 200 threads access this url.
    The result is: single pressure test of the link, multiple tests, the average qps of the application is 87q/s, at this time there are about 13 real-time client connections of the redis library, far from reaching the maximum number of connections MaxTotal configured by jedisPoolConfig 500 and the minimum idle Count 100 MinIdles.
       In the same direction, the current qps of a single online application is about 400q/s, and all the redis library connection pools can be configured at about 65 (although this is not very correct, but at least it can be estimated in this way), because the online business is more complex , so the maximum number of connections in the redis library connection pool MaxTotal is temporarily adjusted to 150.

Reasonable estimated configuration of JedisPoolConfig

JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        //Set the maximum number of instances
        jedisPoolConfig.setMaxTotal(150);
        //Control the maximum number of jedis instances in idle (idle) status in a pool.
        jedisPoolConfig.setMaxIdle(30);
        jedisPoolConfig.setMinIdle(10);
        //Indicates the maximum waiting time when borrowing (introducing) a jedis instance. If the waiting time is exceeded, JedisConnectionException will be thrown directly;
        jedisPoolConfig.setMaxWaitMillis(3 * 1000 );
        // When borrowing a jedis instance, whether to perform the validate operation in advance; if it is true, the obtained jedis instances are all available; 
        jedisPoolConfig.setTestOnBorrow(true);
        // Whether to perform the alidate operation in advance when it is also given to the pool validate operation 
        jedisPoolConfig.setTestOnReturn(true);
        jedisPoolConfig.setTestWhileIdle(true);
        jedisPoolConfig.setMinEvictableIdleTimeMillis(500);
        jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(1000);
        jedisPoolConfig.setTimeBetweenEvictionRunsMillis(1000);
        jedisPoolConfig.setNumTestsPerEvictionRun(100);
        return new JedisPool(jedisPoolConfig, HOST, PORT, 5000, null, 0);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327062145&siteId=291194637