kirktrue commented on PR #17700:
URL: https://github.com/apache/kafka/pull/17700#issuecomment-2585579158

   Thanks for the review @junrao!
   
   > Also, I am wondering why the PR improves the cache eviction rate. If there 
are more consumer clients than allowed session slots, the eviction is always 
going to happen.
   
   True.
   
   From the broker's perspective, the number of partitions in its session cache 
entries fluctuate up and down on a continuous basis. Again, this is because 
fetch requests remove partitions from the cache while they're buffered on the 
consumer and then add them back again after they're "consumed."
   
   When a consumer attempts to create a fetch session on the broker, the 
broker's cache eviction logic will try to evict a "stale" entry or a candidate 
entry with fewer partitions than the new consumer. If an entry is evicted, its 
spot in the cache is snagged by the new consumer.
   
   > This PR only impacts which client will be chosen for eviction, but doesn't 
change the number of evictions, right?
   
   Yes, when eviction is performed, it's a one-for-one swap with the incoming 
consumer. However, eviction is occurring at a much frequency due to the 
volatility of the partition counts in the cache. If the partition counts for 
all consumers remained constant, the eviction logic would resemble something 
more like LRU. 
   
   @jeffkbkim—CMIIW 😄
   
   Thanks!


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to