How many maximum Redis clients(connections) can we expect from Action Cable?

Hi,

I am having some trouble in figuring out how many maximum connections are possible from ActionCable to our Redis instance.

I am investigating this because we get this ERR max number of clients reached error on Heroku whenever connections on Redis cross over 40.

I saw that ActionCable has around 11 or even 15 connections sometimes when I do CLIENT LIST on Redis CLI.

This is our configuration:

  • Heroku Web Dynos - 4
  • Puma Workers - 2 (per dyno)
  • Puma Threads - 5 (per Puma worker)

I also tried changing config.action_cable.worker_size to 1 and reducing the Puma Threads to just 1. Even then I see around 9 connections from ActionCable to Redis.

Note that all of these ActionCable connections have a relatively small “age” and it’s not like some connection stays persistent even if I restart the dynos.

So my question is - how many maximum Redis connections can we expect from Action Cable?

I think, in general, it equals to the number of consumers (open tabs/devises) as the documentation says.

I think, in general, it equals to the number of consumers (open tabs/devises) as the documentation says.

Hi Dmitry,

Thanks for your reply and sorry for the terminologies.

But I was asking about the number of “connections” or “clients” from my app server(Puma) to the Redis instance. I am not particularly interested in the number of “connections” from user’s browser to my web server.

Hi @rakmo,

I’ve struggled with the same question a while back. What I did was to put a breakpoint in ActionCable::SubscriptionAdapter::Redis#redis_connection and then see who is calling it.

I think you’ll find out that for each puma worker, it will create 2 Redis connections. One for subscriptions and one for broadcasts.