Does Heroku still limit Websocket connections?

Lot’s of people are aware that, historically, Heroku is not a good choice for apps that use Websockets. I’m wondering if this has changed in the past 2 years or so.

The first reference I can find to this issue is from back in October 2013

  1. You can maintain around 6,000 open connections on a single dyno
  2. Creating more than 160 connections/sec will cause H11 errors (backlog too deep)

For comparison, an entry-level box from Digital Ocean (512MB RAM, Ubuntu 13.10) can handle 350+ new connections/sec, and seems to max out at around 7,200 open connections.

Heroku WebSocket Performance

Then as of September 2016, a comment posted in StackOverflow says this

“There are no limitations on the free dyno tier in terms of resources. In terms of concurrent connections there is a theoretical limit of 50 connections per Heroku router instance but we don’t currently publicise the number of router instances running at any one time. In general, for the EU region you can expect to have around 1500 connections available at any given time.” --staff reply to me. Later he clarified, this limit is for all dyno types. even paid ones.

Websocket concurrent connections limit on Heroku - Stack Overflow

1500 connections available at any given time, for all dyno types

I am not even 100% sure what this is precisely. 1500 Websocket connections, ie. 1500 users connected to one channel each? Is this equal to 750 users on two channels each?

As a follow-up I looked into Heroku Router

Each router maintains an internal per-app request counter. On the Common Runtime, routers limit the number of concurrent requests per app. There is no coordination between routers however, so this request limit is per router. The request counter on each router has a maximum size of 50n (n = the number of web dynos your app has running). If the request counter on a particular router fills up, subsequent requests to that router will immediately return an H11 (Backlog too deep) response.

HTTP Routing | Heroku Dev Center

50n where n = the number of web dynos running. So what is appears is we would need an additional Redis instance to manage state across different dynos.

Does anyone know if this is true?

WebSockets on Heroku | Heroku Dev Center

2 Likes

I was just running very basic ad hoc browser tests on heroku with a live view app and I did not run into any H11 errors. I didn’t use any ws testing tool, just opened browser tabs. My machine started to fly off the table at 250 chrome tabs. I read a lot of what you posted and I don’t feel it’s a major concern. A single dyno can handle 6k open connections (I have no reason to believe this to have changed) and if the limits are reached one can always scale. Web sockets are now a big part of web development. I have noticed, at least heroku pipelines (https://particleboard.heroku.com/) is using phoenix websockets. So I assume they are aware of the importance.

4 Likes

Asked them about it today and this is what I got:

Hello, and thanks for writing in.

There is a limit to the number to the concurrent websocket connections that your application can handle, getting to the actual figure is complicated, and it depends on how many Dynos your application uses, rather than their type. The details are explained a bit here - HTTP Routing | Heroku Dev Center

Basically you’re limited to 50x connections per Dyno per Router. We have a Router layer that has many machines, and each router can track 50 connections to each Dyno in your app, but each Router is unaware of other Routers. For example, to keep the numbers simple, assuming we have 50 routers, and your app has 5 Dynos, then you can theoretically have 12,500 websocket connections (50 * 50 * 5). Unfortunately we don’t publish the number of active routers as this figure scales as our platform reacts to the current inbound traffic (although you can figure out from the limit that you are hitting that this is currently around 50). However, the more Dynos you run, the more concurrent connections you can handle.

Does this information help you feel more prepared for the expected increase in traffic?

4 Likes

Do I understand this correctly, that Heroku is still not a good option for apps that have lot of living WebSocket connections such as chat rooms etc.?