Can I throttle requests made by a distributed app?

前端 未结 6 1223
无人及你
无人及你 2021-02-13 19:07

My application makes Web Service requests; there is a max rate of requests the provider will handle, so I need to throttle them down.

When the app ran on a single server

6条回答
  •  死守一世寂寞
    2021-02-13 19:34

    Many ways of doing this: you might have a "Coordination Agent" which is responsible of handing "tokens" to the servers. Each "token" represents a permission to perform a task etc. Each application needs to request "tokens" in order to place calls.

    Once an application depletes its tokens, it must ask for some more before proceeding to hit the Web Service again.

    Of course, this all gets complicated when there are requirements with regards to the timing of each calls each application makes because of concurrency towards the Web Service.

    You could rely on RabbitMQ as Messaging framework: Java bindings are available.

提交回复
热议问题