Can I throttle requests made by a distributed app?

前端 未结 6 1231
无人及你
无人及你 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:30

    This is an interesting problem, and the difficulty of the solution depends to a degree on how strict you want to be on the throttling.

    My usual solution to this is JBossCache, partly because it comes packaged with JBoss AppServer, but also because it handles the task rather well. You can use it as a kind of distributed hashmap, recording the usage statistics at various degrees of granularity. Updates to it can be done asynchronously, so it doesn't slow things down.

    JBossCache is usually used for heavy-duty distributed caching, but I rather like it for these lighter-weight jobs too. It's pure java, and requires no mucking about with the JVM (unlike Terracotta).

提交回复
热议问题