How is my message count calculated?

The message count is calculated based on:
 
  1. All calls to our REST API e.g. publish a message, query information on a channel.
  2. Messages delivered to connected clients
  3. WebHook calls made from the Pusher service to your application WebHook endpoint
  4. If you use presence channels within your application then messages are triggered when users join (pusher:member_added) and leave (pusher:member_removed) a channel.
Ping/pong messages used to detect dropped connections and subscription command messages are not counted towards the message count.
 
A Calculation example of Publishing & Subscribing
 
When a message (event) is triggered on a channel and pushed into Pusher it is then distributed to all connected clients that are subscribed to that channel. So, if one message is published on my-channel and 50 clients are subscribed to that channel then the message count will be 51.
var messagesPublished = 1;
var subscribingClients = 50;
var totalMessages = messagesPublished + (subscribingClients * messagesPublished);
// 1 + (50 * 1)
alert(totalMessages); // 51
 
An example with bigger numbers and more messages published, but still with a single channel would be where there are 500 subscribed clients and 40,000 messages published. The 40,000 messages would be delivered to all 500 connected clients resulting in 20,000,000 messages being delivered. So the total message count would be 20,000,000 + 40,000:
var messagesPublished = 40000;
var subscribingClients = 500;
var totalMessages = messagesPublished + (subscribingClients * messagesPublished);
// 40000 + (500 * 40000)
alert(totalMessages); // 20040000
 
The example above highlights the need to use channels to filter messages so that clients only received the information they are really interested in. Let's take an example with the following scenario:
  • there are 100 channels used to filter the data into categories
  • 100 clients are interested in all events on all channels
  • 100 clients are interested in data from 50 channels
  • the remaining 300 clients are subscribed to just 1 channel
  • the 40000 messages are distributed between all channels leading to 400 messages per channel
The message consumption values would be as follows:
  • 100 clients receive all messages on all channels = (100 * 400 * 100) = 4,000,000 messages
  • 100 clients receive messages on 50 channels = (100 * 400 * 50) = 2,000,000 messages
  • 300 clients receive messages on 1 channel = (300 * 400 * 1) = 120,000 messages
Which is a total of 6,120,000 messages delivered. Add that to the number of messages published means that 6,160,000 messages in total.
 
Although quite complicated this hopefully shows that by filtering the messages using channels that the number of messages delivered can be vastly reduced. In the case above the number of messages delivered has decreased by a massive 13,880,000.
 
More
 
More information on message quotas please see the plans on our pricing page.
Was this article helpful?
2 out of 2 found this helpful
Haven't found what you were looking for?
Submit a ticket