zoukankan      html  css  js  c++  java
  • rate limiter

    1 问题

    Whenever you expose a web service / api endpoint, you need to implement a rate limiter to prevent abuse of the service (DOS attacks).

    Implement a RateLimiter Class with an isAllow method. Every request comes in with a unique clientID, deny a request if that client has made more than 100 requests in the past second.

    这是一个流控问题。

    2 输入

    Request:

    client ID和时间戳timestamp

    3 输出

    true or false

    4 思路

    保存每个client ID过去1s的所有请求。

    数据结构?

    5 关于guava的RateLimiter

    5.1 RateLimiter在下列应用场景中的应用

    https://www.cnblogs.com/yeyinfu/p/7316972.html

    5.2 RateLimiter用在接口中不会超时吗?

    比如限制访问数据库,每秒不超过10,使用RateLimiter的本质是每个请求等待0.1秒。这不会导致请求超时吗?

    5.3 抢购场景降级 tryAcquire()

    6 限流算法:令牌桶算法和漏桶算法

  • 相关阅读:
    P、NP、NPC、NPH问题介绍
    过河卒 bfs搜索
    对迪杰斯特拉算法的理解
    第七周
    周作业
    月考一
    第四周
    第三周
    第二周作业
    46期第一次作业
  • 原文地址:https://www.cnblogs.com/hustdc/p/10950253.html
Copyright © 2011-2022 走看看