You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hotspot Parameter Rate Limiting - Queuing Strategy Batch Count Explosion
In the queuing waiting strategy for hotspot parameter rate limiting:
The first request is default allowed (no waiting)
Subsequent requests are scheduled based on lastPassTime. When lastPassTime is stale (long elapsed), the rate limiter may allow a massive batchCount (far exceeding Threshold)
Describe what you expected to happen
I expect that under this strategy, if batchCount exceeds the threshold, it needs to be rejected, and maxQueuingTime can also be taken into account to increase the threshold.
How to reproduce it (as minimally and precisely as possible)
modify hotspot_params_qps_throttling_example.go
func main() {
conf := config.NewDefaultConfig()
// for testing, logging output to console
conf.Sentinel.Log.Logger = logging.NewConsoleLogger()
err := sentinel.InitWithConfig(conf)
if err != nil {
log.Fatal(err)
}
_, err = hotspot.LoadRules([]*hotspot.Rule{
{
Resource: "def",
MetricType: hotspot.QPS,
ControlBehavior: hotspot.Throttling,
ParamIndex: 1,
Threshold: 1000,
MaxQueueingTimeMs: 5,
DurationInSec: 1,
},
})
if err != nil {
log.Fatalf("Unexpected error: %+v", err)
return
}
logging.Info("[HotSpot Throttling] Sentinel Go hot-spot param flow control demo is running. You may see the pass/block metric in the metric log.")
for {
e, b := sentinel.Entry("def", sentinel.WithArgs(false, uint32(9), "ahas", fooStruct{rand.Int63() % 5}), sentinel.WithBatchCount(2000))
if b != nil {
// Blocked. We could get the block reason from the BlockError.
} else {
// Passed, wrap the logic here.
// Be sure the entry is exited finally.
e.Exit()
}
time.Sleep(time.Duration(3) * time.Second)
}
// The QPS of abc is about: 15000
// The QPS of def is about: 950
}
I want to discuss whether this situation is in line with expectations. I understand that the batchCount that exceeds the threshold should be limited, which is also what users expect. If necessary, I can submit a PR to fix this problem.
Thank you for the detailed analysis! I agree that when the first request arrives (or after lastPassTime expires), sentinel should evaluate the request against the threshold and maximum wait time. We welcome your PR to implement this fix – please let me know if you need any context or guidance!
You can assign this issue to me and I will submit a PR as soon as possible.
Thank you for the detailed analysis! I agree that when the first request arrives (or after lastPassTime expires), sentinel should evaluate the request against the threshold and maximum wait time. We welcome your PR to implement this fix – please let me know if you need any context or guidance!
Issue Description
Type: bug report
Describe what happened
Hotspot Parameter Rate Limiting - Queuing Strategy Batch Count Explosion
In the queuing waiting strategy for hotspot parameter rate limiting:
Describe what you expected to happen
I expect that under this strategy, if batchCount exceeds the threshold, it needs to be rejected, and maxQueuingTime can also be taken into account to increase the threshold.
How to reproduce it (as minimally and precisely as possible)
modify hotspot_params_qps_throttling_example.go
output
Tell us your environment
Anything else we need to know?
The text was updated successfully, but these errors were encountered: