How does Ably count peak connections?

Ably accounts are priced based on the total number of messages, peak channels and peak connections within any calendar month.  Find out more about account limits and check our pricing page to find out how much it costs to upgrade your package to support more connections.

The peak connection figure is the maximum number of realtime clients simultaneously connected to Ably at any point in time within the month.  For example, if you have 10,000 customers, and at your busiest time of the month there is a single spike with 500 customers with a realtime connection open to Ably, you will only be charged for 500 peak connections.  The total number of clients or devices that connect to Ably throughout the month does not affect your bill.

Tip: HTTP requests and connections used by REST clients do not count towards your peak connections.

In your account or app dashboard, the graph at the bottom of the page shows the minimum, maximum (peak) and average number of connections for the time period.  See an example below:

How does Ably count peak connections?

Further technical details on how connections are counted in real time

Each Ably frontend server that accepts connections from clients counts the number of transports that are connected for a given app. The most common transport is WebSockets, however in order to support older browsers or very restrictive network environments, additional HTTP transports such as XHR and JSONP are supported. The total number of connected transports per app and account counts up each time a transport is connected, and down each time one is dropped.

These counts are updated when they change in a hash of connections maintained for each datacenter, and the counts and are then rolled up globally once every second i.e. viewing your live connection counts will be inaccurate by at least one second.

If a frontend server is abruptly terminated and thus all transports are closed, the corresponding member of the datacenter maintained hash is deleted ensuring we never miscount as a result of an abruptly terminated instance being unable to decrement the central count.

The usage stats for an account or app viewable in your dashboard (which includes message counts, peak channels etc) is aggregated every few seconds and persisted to disk in at least 2 regions.

Whenever account aggregates are calculated and persisted to disk, the connections, channels, messages and data used for that month are checked against the account package limits, and an appropriate action is taken if a limit is exceeded i.e. a notification may be sent to Ably staff instructing them to contact the customer, or, in severe cases, new connections or messages will be rejected on that account.  Find out more about what happens if you exceed your account package limits.