# RPC 漫谈： 限流问题

DevFeed: [RPC 漫谈： 限流问题](<https://devfeed.tech/articles/rpc-40976.md>)

Original publisher: [Read original article](<https://blog.joway.io/posts/deep-into-rpc-ratelimiter/>)

Author: Joway

Published: 2021-04-23T00:00:00Z

Content type: opinion

Language: zh

Sources: [Random Thoughts](<https://devfeed.tech/sources/random-thoughts.md>)

Topics: [Remote Procedure Call (RPC)](<https://devfeed.tech/topics/rpc.md>), [Server](<https://devfeed.tech/topics/server.md>), [client](<https://devfeed.tech/topics/client.md>), [IO](<https://devfeed.tech/topics/io.md>), [Network](<https://devfeed.tech/topics/network.md>), [cpu](<https://devfeed.tech/topics/cpu.md>)

Tags: [client](<https://devfeed.tech/tags/client.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [io](<https://devfeed.tech/tags/io.md>), [network](<https://devfeed.tech/tags/network.md>), [rpc](<https://devfeed.tech/tags/rpc.md>), [server](<https://devfeed.tech/tags/server.md>), [service-mesh](<https://devfeed.tech/tags/service-mesh.md>), [tech](<https://devfeed.tech/tags/tech.md>)

## AI overview

This article examines rate limiting for RPC calls between microservices. It explains why fixed limits can help prevent cascading failures and preserve response times, then discusses the limitations of leaky-bucket and token-bucket approaches. The article argues that service capacity changes with code, dependencies, hardware, node count, business demand, and time of day. It proposes estimating current load using concurrent in-flight requests, average response time, and throughput, drawing on Little's law, and describes the trade-off between increased throughput and degraded response time under resource contention.

## Source excerpt

微服务之间的 RPC 调用往往会使用到限流功能，但是很多时候我们都是用很简单的限流策略，亦或是工程师拍脑袋定一个限流值。 这篇文章主要讨论在 RPC 限流中，当前存在的问题和可能的解决思路。 为什么需要限流 避免连锁崩溃 一个服务即便进行过压测，但当真实运行到线上时，其收到的请求流量以及能够负载的流量是不固定的，如果服务自身没有一个自我保护机制，当流量超过预计的负载后，会将这部分负载传递给该服务的下游，造成连锁反应甚至雪崩。