Search code examples
performanceredisconnection-pooling

Default connections hold by JedisPool


I am integrating redis with ofbiz by using jedis client. One redis server is being used by different application. My question is

  1. How many connection will be hold by JedisPool by default.

  2. If I create multiple JedisPool will it effect redis performance

Note : I am creating JedisPool with default configuration in another application.

client = new JedisPool(ip, port);

Is there any better approach?, suggest me. Thanks

Update : Initiating redis server with default configuratoin user spring data

<bean id="connectionFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
    p:host-name="${app.cache.redis.host}" p:port="${app.cache.redis.port}" p:password="${app.cache.redis.password}" />

Solution

  • 1) How many connection will be hold by JedisPool by default

    By using JedisPool with this instantiation,

    client = new JedisPool(ip, port);
    

    you are using a GenericObjectPoolConfig from apache-commons-pool.

    The default configuration for this generic pool is:

    DEFAULT_MAX_TOTAL = 8
    DEFAULT_MAX_IDLE = 8
    DEFAULT_MIN_IDLE = 0
    

    2) If I create multiple JedisPool will it effect redis performance

    Yes and no. If you create multiple JedisPool, you will have more clients connected to Redis. But Redis can support a lot of connected clients with very good performance.

    You can set the Redis max client authorized number in redis.conf (for example 10000 clients max).

    maxclients 10000
    

    or at startup :

    ./redis-server --maxclients 10000
    

    or with redis-cli :

    127.0.0.1:6379> config set maxclients 10000
    

    In the default configuration, the number of authorized clients is unlimited.

    Depending of your use case, you can have multiple JedisPool, or simply increase the size of your JedisPool (to have more than 8 connections).