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

Simple request: allow disconnecting all users #56

Closed
banks opened this issue Dec 23, 2015 · 5 comments
Closed

Simple request: allow disconnecting all users #56

banks opened this issue Dec 23, 2015 · 5 comments

Comments

@banks
Copy link
Member

banks commented Dec 23, 2015

There is already an admin API for disconnecting specified user.

In some cases (handling outages/load testing) it can be useful to explicitly disconnect all current users such that they won't attempt to reconnect indefinitely (in the wild we always have some people who leave the page open for days and days).

It's not vital, but it would be useful in these cases to be able to force-disconnect every user.

Could support empty userid param, but probably better would be something explicit like ** so it can't be done accidentally...

@FZambia
Copy link
Member

FZambia commented Dec 25, 2015

Empty string already used as a sign to make operation with all things - in unsubscribe command empty channel unsubscribes user from all channels. So I think empty string should be ok to keep support the same semantics. At moment Centrifugo just closes connections when processes disconnect API cmd, now we need to send disconnect message to clients. As you know there is reconnect flag in it. This reconnect flag will be optionally set in web interface and by default will be true I suppose - so even if disconnect button was pressed accidentally from web interface - users will reconnect.

@FZambia
Copy link
Member

FZambia commented Dec 30, 2015

Can make this empty string const at moment and then move to configuration if needed. The problem I came across while thinking how to make this is that disconnecting all users is operation that takes a time - so some of users can disconnect and even reconnect during this operation (especially if application has many users). So I can't decide - is this ok or not? What can we do with this case and should we? Just locking client hub won't help as new connections will be just queued for a while. Setting extra flags on the time of operation looks like overengineering. @banks whats your thoughts?

@banks
Copy link
Member Author

banks commented Dec 30, 2015

Yeah so this is not as simple as I thought - I assumed disconnect already sent message back to client.

So let me re-state what I actually want rather than just suggest we change this existing feature.

What would be useful in some cases would be te ability to put a whole centrifguo cluster into "load shedding" mode where they:

  • deny incoming requests with a permanent error
  • close all existing connections with a reconnect: false message

The motivation is that in real-world we see clients still connected weeks after stopping a load test of centrifugo. For example, I ran a load test which had about 50k users connected and I still see about 100 users connected now - over a week since I stopped including JS on the page that makes the connections! For first 24 hours after load test it's in the thousands.

One way to achieve this would be to have some application property that is checked on each request (like config properties are) and then just make and admin API to toggle it with enough warnings about how destructive it is.

Honestly not sure if it's worth it though if it's relatively hard to do. There are other ways to acheive same thing - alter HMAC secret and restart for a while so that all the reconnects are failed permenantly due to bad auth for example. (not tried that but I assume it would work).

@FZambia
Copy link
Member

FZambia commented Dec 31, 2015

Trick with altering secret should help.

There is already shutdown method called when SIGINT received. And shutdown property in application. Maybe try to make shutdown as button in web interface? At moment on shutdown connections just closed - so will reconnect, maybe shutdown with optional reconnect flag? But anyway there may be some users that have not processed disconnect message and will try to reconnect.

@FZambia
Copy link
Member

FZambia commented May 22, 2018

Closing with won't do resolution, because as time goes there is still no obvious solution. Hopefully this is a rare requirement and changing secret can be a reasonable workaround to solve this case.

@FZambia FZambia closed this as completed May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants