---
source_url: https://www.pubnub.com/docs/design-patterns/load-test-large-room
title: Load test a large live event channel
description: Fill a testing channel with simulated viewers before a live event, then check the count, the badge, the roster, and reconnects against a known record.
updated_at: 2026-11-20T09:51:54.000Z
---

# Load test a large live event channel

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

This guide shows you how to load test a live event channel with simulated viewers before the event. Read [Large-room presence for live events](https://www.pubnub.com/docs/design-patterns/large-room-presence.md) first for what the test checks.

Before you start:

* Create a testing keyset with the same Presence Management rules, Announce Max, interval, and **Presence Deltas** setting as production.
* Check that the rule covers the event channel and includes the `interval` event type. Otherwise the room stays silent, or the count stays at zero.
* Run a few real viewers next to the simulated ones, with your viewer code. Simulated viewers test presence only. They don't receive messages.
* Size the test to your budget. Every heartbeat is a billable request.

## Simulate viewers

1. Send one heartbeat per simulated viewer, with its own User ID. The function below returns the record you compare against later. Keep that record.

   ```javascript
   // One simulated viewer: a heartbeat with its own User ID. Keep the record.
   // It's the truth you compare against later.
   async function joinViewer(userId) {
     const url =
       `https://ps.pndsn.com/v2/presence/sub_key/${SUBSCRIBE_KEY}/channel/${encodeURIComponent(CHANNEL)}/heartbeat` +
       `?uuid=${encodeURIComponent(userId)}&heartbeat=300`;
     const sentAt = Date.now();
     const response = await fetch(url);
     return { userId, sentAt, returnedAt: Date.now(), ok: response.status === 200 };
   }
   ```

2. Send the heartbeats through a concurrency limit, and retry failures with backoff. Front-load the arrivals so they match your real audience.
3. Repeat each simulated viewer's heartbeat before its `heartbeat` value (300 seconds in the code) passes. This keeps the viewer counted.

## Check the results

During a burst, the true count is a range. It runs from the viewers whose heartbeat had returned before your check started, to the viewers whose heartbeat had gone out before your check returned. Compare each result against that range.

1. **Count accuracy.** Check that each count-only `Here Now` result falls inside the range for the time the call was in flight.
2. **Update lag.** Compare each `interval` event's `occupancy` with the range at the moment PubNub cut it, during the burst and after it.
3. **Badge correctness.** Check each real client's badge against the range, especially in the first 30 seconds of the burst.
4. **Roster correctness.** After the room is quiet for a full interval, compare the roster's set with your record. Count the missing User IDs and the extra ones.
5. **Refresh path.** Confirm the roster sees `hereNowRefresh: true` during the burst, and matches `occupancy` after the room settles. Don't assert on the number of pages a read takes.
6. **Reconnects and departures.** Have one group reconnect with the same User ID, one reload with fresh IDs, and one go silent. Check the count against [Plan for reconnects and departures](https://www.pubnub.com/docs/design-patterns/large-room-presence.md#plan-for-reconnects-and-departures).

Response times from one test machine describe that machine, not the platform.

## Related tasks

* [Show a viewer count for a large live event](https://www.pubnub.com/docs/design-patterns/show-viewer-count-large-room.md). The badge logic the test checks.
* [Build a roster for a large live event](https://www.pubnub.com/docs/design-patterns/build-roster-large-room.md). The roster logic the test checks.
* [API limits](https://www.pubnub.com/docs/architecture/limits.md#presence). Announce Max, interval range, and heartbeat limits.

Last updated at: 2026-11-20T09:51:54.000Z
