{"record":{"id":"301e514483bb8e5e","repo":"Netflix/Hystrix","slug":"the-timeinmilliseconds-must-divide-equally-into-nu","errorCode":null,"errorMessage":"The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.","messagePattern":"The timeInMilliseconds must divide equally into numberOfBuckets\\. For example 1000/10 is ok, 1000/11 is not\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java","lineNumber":83,"sourceCode":"     * @deprecated Please use {@link HystrixRollingNumber(int, int) instead}.  These values are no longer allowed to\n     * be updated at runtime.\n     */\n    @Deprecated\n    public HystrixRollingNumber(HystrixProperty<Integer> timeInMilliseconds, HystrixProperty<Integer> numberOfBuckets) {\n        this(timeInMilliseconds.get(), numberOfBuckets.get());\n    }\n\n    public HystrixRollingNumber(int timeInMilliseconds, int numberOfBuckets) {\n        this(ACTUAL_TIME, timeInMilliseconds, numberOfBuckets);\n    }\n\n    /* package for testing */ HystrixRollingNumber(Time time, int timeInMilliseconds, int numberOfBuckets) {\n        this.time = time;\n        this.timeInMilliseconds = timeInMilliseconds;\n        this.numberOfBuckets = numberOfBuckets;\n\n        if (timeInMilliseconds % numberOfBuckets != 0) {\n            throw new IllegalArgumentException(\"The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.\");\n        }\n        this.bucketSizeInMillseconds = timeInMilliseconds / numberOfBuckets;\n\n        buckets = new BucketCircularArray(numberOfBuckets);\n    }\n\n    /**\n     * Increment the counter in the current bucket by one for the given {@link HystrixRollingNumberEvent} type.\n     * <p>\n     * The {@link HystrixRollingNumberEvent} must be a \"counter\" type <code>HystrixRollingNumberEvent.isCounter() == true</code>.\n     * \n     * @param type\n     *            HystrixRollingNumberEvent defining which counter to increment\n     */\n    public void increment(HystrixRollingNumberEvent type) {\n        getCurrentBucket().getAdder(type).increment();\n    }\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java#L65-L101","documentation":"HystrixRollingNumber splits a rolling window of timeInMilliseconds into numberOfBuckets, computing bucketSizeInMilliseconds = timeInMilliseconds / numberOfBuckets. The constructor validates that the division is exact; a non-zero remainder means the window and buckets cannot represent consistent time slices, so an IllegalArgumentException is thrown at construction.","triggerScenarios":"Constructing HystrixRollingNumber(timeInMilliseconds, numberOfBuckets) where timeInMilliseconds % numberOfBuckets != 0, e.g. new HystrixRollingNumber(1000, 11) or misconfigured metrics window properties (metrics.rollingStats.timeInMilliseconds not divisible by metrics.rollingStats.numBuckets) on commands or thread pools.","commonSituations":"Setting hystrix.command.<key>.metrics.rollingStats.timeInMilliseconds=5000 with numBuckets=12; copying example configs with incompatible pairs; unit tests instantiating HystrixRollingNumber directly with odd numbers.","solutions":["Pick numBuckets that divides timeInMilliseconds evenly (e.g. 10000ms/10 buckets, 5000ms/10 buckets).","If the values come from config, validate the pair at startup: assert window % buckets == 0 and fail fast with a clear config error.","Keep the documented constraint that bucket duration (window/buckets) should be >= 100ms for meaningful metrics."],"exampleFix":"# before\nhystrix.command.orders.metrics.rollingStats.timeInMilliseconds=5000\nhystrix.command.orders.metrics.rollingStats.numBuckets=12   # 5000 % 12 != 0\n\n# after\nhystrix.command.orders.metrics.rollingStats.timeInMilliseconds=6000\nhystrix.command.orders.metrics.rollingStats.numBuckets=12   # 500ms buckets","handlingStrategy":"validation","validationCode":"static void checkRollingWindow(int timeMs, int numBuckets) {\n    if (timeMs % numBuckets != 0) {\n        throw new IllegalArgumentException(\"timeInMilliseconds (\" + timeMs + \") must be divisible by numberOfBuckets (\" + numBuckets + \")\");\n    }\n}\n// run against config values before building commands/thread pools","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate rolling-stats window/bucket pairs at config load time and fail fast.","Use documented pairs like 10000/10 or 60000/12."],"tags":["hystrix","metrics","configuration","validation"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}