Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] presence with massive amount of active users #335

Open
morya opened this issue Nov 13, 2023 · 6 comments
Open

[feature] presence with massive amount of active users #335

morya opened this issue Nov 13, 2023 · 6 comments

Comments

@morya
Copy link

morya commented Nov 13, 2023

Is your feature request related to a problem? Please describe.

presence

It works well (for channels with reasonably small number of active subscribers though)

but, it has a natual limit when users grow in a channel.

because of the implementation and msg definition from https://github.com/centrifugal/protocol/blob/43664d12bdd9086315ccdb96c742618a4ea6b3b0/client.proto#L245

Describe the solution you'd like

I am considering adding a new command, to scan all users from engine(memory/redis), and send it with batch reply.
Like this:

for {
  // 1. scan redis hash keys
  // 2. build repeated response
  // 3. send to client
  if loopIsDone { 
    break
  }
}

Describe alternatives you've considered

no

Additional context

sometimes, it could useful for admin to retieve all users inside one big channel.

@FZambia
Copy link
Member

FZambia commented Nov 15, 2023

Hello @morya ,

You are talking about admin needs, but showing client protocol - I think this should not be part of it, at least at first. For now, a method for Node could be a good start.

Presence for each channel is now kept in single Redis HASH - so there is nothing to scan actually - it's a single key.

In general I'd like to provide more scalability here, it requires more thinking and analysis than provided above.

@FZambia FZambia changed the title [feature] presence with masive amount of active users [feature] presence with massive amount of active users Nov 15, 2023
@morya
Copy link
Author

morya commented Nov 15, 2023

Yes, it's a admin API, but, the client protocol has precense call too.

what I mean with redis scan, hgetall could block redis for a while potentially.

And, true, redis scan is not the best solution here.

I was thinking a sync method, like sync between etcd nodes, or sync/psync between redis master/slave.

It could be a heave lifting...

clients will always see all users, won't miss a single join/leave status, maybe a filter to see range of users.

BR

@FZambia
Copy link
Member

FZambia commented Dec 14, 2023

Another way could be shard presence to load it chunk by chunk from different keys, sth like pagination. For example, you in channel with 100k subscribers, we could set shard number == 10, and then somehow distribute information over those keys. Not sure about exact algorithm and API for this – just an idea for now.

I'd also like to mention that in Centrifugo PRO we approach the need in massive presence analysis by using ClickHouse analytics - i.e. using a system which can provide access to massive data in near real-time.

@morya
Copy link
Author

morya commented Dec 14, 2023

for now, we use a hack method by read from redis directly with command hscan xxx.

but, it's not a quite an elegant nor accurate method, when doing both subscribing join/leave messages and read from hscan results.

there is no way to keep eventually consistency data.

that's why I metioned sync between etcd nodes, or sync/psync between redis master/slave

I think it could be a way, like subscribing psync protocol data from a follower redis , and parse them, convert them into join/leave messages.

but it seems quite complicated

@FZambia
Copy link
Member

FZambia commented Dec 28, 2023

Yes, it's complicated... Possibly, for such scale you need different model, with some approximation. Sth like mentioned approach with ClickHouse, or some other store. Heavily depends on the target use case – since you have not described it I am just trying to give you alternative directions of thinking.

@morya
Copy link
Author

morya commented Dec 29, 2023

Thanks, really appreciate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants