How to prevent channel flooding?

What is the best method of preventing a phoenix app with channels to be flooded by some malicious client?
I guess some kind of counter, however I would like to ask the creators / people with deeper knowledge how to do this the right way?
Thank you!

2 Likes

One way i could think of is to rate limit or throttle incoming messages…

1 Like

Yes, that was what I was asking for. How would you implement this? Is there anything that comes with phoenix / elixir / erloang that helps me in not-reinventing the wheel?

Thanks again for your attention!

1 Like

There are several algorithms I know of, widely used token bucket.
You can find existing implementations on hex.pm (for example https://hex.pm/packages/ex_rated and forks).
I might be mistaken, but throttling in that case would be same algorithm but instead of dropping off-limit connections you will queue them…

2 Likes