Hystrix中healthSnapshot.intervalInMilliseconds与rollingStats.timeInMilliseconds差异咨询
Hystrix: Difference Between
healthSnapshot.intervalInMilliseconds and rollingStats.timeInMilliseconds Hey there! Let's break down these two Hystrix configuration properties clearly—they serve distinct purposes, so it's common to mix them up when first setting up circuit breakers.
What does hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=500 do?
This property controls how often Hystrix takes a "snapshot" of your command's health metrics (like success rate, error count, timeout rate, etc.).
- Setting it to 500ms means Hystrix will check and capture the latest health stats every 500 milliseconds (half a second).
- This directly impacts how quickly your circuit breaker can react to changes in your command's performance. A shorter interval makes the breaker more responsive to sudden failures, but comes with a tiny performance overhead from more frequent metric checks. A longer interval delays state updates but reduces that overhead.
What does hystrix.command.default.metrics.rollingStats.timeInMilliseconds=600000 do?
This property defines the total time window for rolling statistical calculations that Hystrix uses to determine your command's health.
- 600000ms equals 10 minutes—so Hystrix will only consider request data from the last 10 minutes when calculating metrics like error rate.
- This window is split into smaller "buckets" (controlled by
rollingStats.numBuckets, default 10), so a 10-minute window would have 6-minute buckets. Hystrix aggregates data across these buckets to get the overall stats for the full window. - A larger window makes your circuit breaker more resistant to short-term traffic spikes or transient failures (it won't trip just because of a 30-second blip). A smaller window makes it more sensitive to recent performance issues.
Key Differences at a Glance
- Core Purpose:
healthSnapshot.intervalInMilliseconds: Frequency of health checks (how often we check the stats)rollingStats.timeInMilliseconds: Time range of stats used (how far back we look for data)
- Impact on Circuit Breaker:
- The snapshot interval determines how fast the breaker updates its state (open/closed/half-open).
- The rolling stats window determines the "context" of the data used to make that state decision.
- Example Interaction: If you set the rolling window to 10 minutes and the snapshot interval to 500ms, Hystrix will recalculate the 10-minute error rate every half second, and use that updated rate to decide if the circuit should trip.
内容的提问来源于stack exchange,提问作者Sudha Rajamanickam
相关产品推荐
相关产品推荐

