简体   繁体   中英

How is computed the redis connection pool size in a multi-dyno environment when using a spring cloud connectors configuration?

My application is configured as follows:

@Bean
public RedisConnectionFactory redisConnectionFactory() {
        PoolConfig poolConfig = new PoolConfig(10, 200);// maxPoolSize=10
        return connectionFactory().redisConnectionFactory("REDISCLOUD", new PooledServiceConnectorConfig(poolConfig));
    }

The entry plan for REDISCLOUD indicates a maximum of 10 Redis connections.

However, I have two running dynos at the moment and I might have more than two in the future. Does that mean that my app can consumes 2 dynos * 10 connections = 20 Redis connections at the moment?

If that is the case that's an issue and I am not sure how to configure my pool for instance if I increase the number of running dynos...

By the way the issue is the same with relational database connectors...

Can someone please advise?

Disclaimer : I work at Redis Labs, provider of the Redis Cloud add-on for Heroku.

You are correct - this setup will require 20 connections if each dyno's pool grows to the maximum. Connections to the database are considered an "expensive" resource - both for client and for server. That's exactly why connection pools are used by applications... and also why database providers, such as Redis Labs, need to charge for them.

One way to overcome this is to upgrade your Redis Cloud add-on plan to suit your connection requirements :) The paid plans are much more permissive and starting at the 2.5GB plan, you get an unlimited number of connections. Using one of these you can stop worrying about scaling: https://addons.heroku.com/rediscloud#2500

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM