Giter Site home page Giter Site logo

Comments (2)

FZambia avatar FZambia commented on May 30, 2024

Hello @sky93

Centrifugo does not have sth like this available at the moment, and no plans to add it in the observable future. In general, would be nice to have built-in option to quickly configure – but need to consider how to integrate it with everything else in Centrifugo and distributed environment.

I guess the most effective solution is reducing on the layer before Centrifugo – probably add in-memory rate limiters on your publisher side.

Or add some rate limiting proxy between publisher and Centrifugo. I suppose Nginx can be such proxy - it has built-in leaky bucket limiting and I believe it's possible to configure it to take channel into account. Sth like this (did not test it):

http {
    # Define a key for rate limiting based on the 'channel' URL parameter.
    map $arg_channel $limit_key {
        default "";
        "~^(.+)$" $1;
    }

    limit_req_zone $limit_key zone=per_channel:10m rate=1r/2s;

    server {
        listen 80;
        server_name yourserver.com;

        location /api/publish {
            limit_req zone=per_channel burst=0 nodelay;
            proxy_pass http://centrifugo-upstream;
        }
    }
}

And add channel to request URL when using publish API so that proxy could extract it and rate limit based on it.

But that's just an example. I guess you may find other ways to reduce number of messages published.

What do you think? What is the use case btw where you have 2k messages in a single channel?

from centrifugo.

sky93 avatar sky93 commented on May 30, 2024

Thank you very much for your detailed response. My use case involves handling market data, where we have multiple markets with frequent updates in price. Given the volume and frequency of data updates, your suggestion to implement an in-memory rate limiter on the publisher side or a rate limiting proxy like Nginx is particularly relevant.

I will look into adapting it to our needs and test its efficacy in managing the data flow to Centrifugo.

Thank you once again for your guidance.

from centrifugo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.