Photon Engine Interest Groups: Filtering Room Events by Relevance, Not Broadcast
Photon Realtime's interest groups let clients filter room events by relevance instead of receiving every broadcast. Learn how to partition events, avoid common pitfalls, and verify the setup works correctly.
18 Jan 2026, 19:56 UTC

The Problem: Wasting Bandwidth on Irrelevant Events
In a multiplayer game, every player in a Photon room receives every event by default. A 20-player room broadcasting position updates, chat messages, and game events floods each client with data they might not care about—especially in large or spatially-partitioned worlds. This wastes bandwidth, increases latency, and can hit Photon's message rate limits faster than necessary.
Thesis: Interest Groups as a Relevance Filter
Photon Realtime's interest groups let clients subscribe to numeric groups and receive only events sent to those groups. Rather than treating all room events as universally relevant, you can partition events by spatial zones, feature flags, or gameplay contexts. This reduces traffic per client without changing the room's core messaging system.
How Interest Groups Work
Each client maintains a subscription set—a bitfield indicating which groups it listens to. When you call RaiseEvent, you specify a group number. Photon delivers that event only to actors whose subscription set includes that group. The groups are not a security boundary: any actor in the room can subscribe to any group number, and all events are still visible in the room's event stream on the server side.
Key Behaviors to Remember
- Subscriptions are client state: They reset on disconnect, room rejoin, or scene reload. Your code must re-establish subscriptions when appropriate.
- Group 0 is special: It's the default group and cannot be unsubscribed from. Events sent to group 0 reach all actors.
- SDK differences exist: Unity PUN 2 wraps the low-level API; direct C# or JavaScript clients use
RaiseEventOptionswith theGroupIdfield.
Practical Example: Nearby Chat with Zone Groups
Imagine a top-down shooter where players can send chat messages visible only to others in the same quadrant. Divide the map into four zones, each mapped to groups 1–4.
Client-Side Implementation (Unity PUN 2)
// When player enters zone 2
void OnZoneEnter(int zoneId) {
// zoneId is 1-4, maps directly to interest group
PhotonNetwork.SetInterestGroups(zoneId, zoneId);
// Also enable group 0 for global events like game start
PhotonNetwork.SetInterestGroups(0, 0);
}
// Sending a chat message to current zone only
void SendZoneChat(string message) {
var ev = new RaiseEventOptions {
Content = message,
CacheOptions = EventCacheOptions.AddToRoomList,
TargetGroups = new byte[] { (byte)currentZoneId }
};
PhotonNetwork.RaiseEvent(eventChat, ev, new SendOptions(), true);
}
Verification Steps
- Spawn three clients in the same room. Assign client A to group 1, client B to group 1, and client C to group 2.
- Have client A send an event to group 1. Confirm B receives it and C does not.
- Call
PhotonNetwork.SetInterestGroups(2, 2)on client B. Re-send the event. B should now receive events for group 2. - Disconnect and rejoin client B. Verify it must re-subscribe to groups 1 and 2 to continue receiving those events.
Trade-offs and Limitations
Interest groups solve bandwidth filtering but come with constraints:
- Not a security mechanism: Any client can subscribe to any group. Never rely on this to hide cheat-critical information.
- Plan limits apply: Photon's message rate and CCU limits are per room. Reducing irrelevant traffic helps you stay within these caps, but you still need to design around them.
- Group number collision: If you use groups for both spatial zones and feature flags, establish a shared mapping to avoid unintended overlaps.
- Server-side variance: Behavior differs slightly between Photon Cloud and self-hosted Photon Server. Test against your deployment target.
Actionable Closing: Start Small, Verify Often
Begin by identifying one event stream that's universally broadcast but only relevant to subsets of players—nearby chat, zone-specific triggers, or local particle effects. Implement interest groups for that stream, then run the verification steps above to confirm filtering works as expected. Monitor your Photon Cloud dashboard for message volume changes after deployment. If you're approaching plan limits, expand the pattern to other event types, but always keep validation logic server-side or in trusted webhooks.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.