lhotari commented on code in PR #24423: URL: https://github.com/apache/pulsar/pull/24423#discussion_r2262571266
########## pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java: ########## @@ -437,11 +449,37 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception { } } + protected void checkRateLimit(BaseCommand cmd) { + if (cmd.getType() == BaseCommand.Type.PONG && cmd.getType() == BaseCommand.Type.PING) { + return; + } + if (requestRateLimiter.acquire(1) == 0) { + log.warn("[{}] Reached rate limitation", this); + // Stop receiving requests. + pausedDueToRateLimitation = true; + ctx.channel().config().setAutoRead(false); + // Resume after 1 second. + ctx.channel().eventLoop().schedule(() -> { + if (pausedDueToRateLimitation) { + log.info("[{}] Resuming connection after rate limitation", this); + ctx.channel().config().setAutoRead(true); + pausedDueToRateLimitation = false; + } + }, 1, TimeUnit.SECONDS); + } Review Comment: In my PIP-434, I've explained that auto read shouldn't be toggled directly. You must use ServerCnxThrottleTracker instead. The channel must be throttled if any of the conditions for throttling are present. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org