Groups allow you to categorize connections. This is the most efficient way to scale real-time updates for thousands of users.
Groups are dynamic. One line of code: await Groups.AddToGroupAsync(Context.ConnectionId, "Department_101"). You don't need to 'Create' a group; it exists as soon as someone is in it. When a user logs out or leaves a page, make sure to remove them to prevent 'Ghost' updates.
Groups are **not** persisted. If the server restarts, the group memberships are gone. If you need groups to survive a restart, you must re-add the users to the groups in the OnConnectedAsync method by checking their permissions in your database.
Q: "Can a user be in multiple groups?"
Architect Answer: "YES. A user can be in 'Global_Alerts', 'Department_Sales', and 'Project_X' simultaneously. This allows you to push 'Public', 'Private', and 'Team' notifications with zero extra overhead. Groups are the 'Taggant' system of real-time communication."