{"record":{"id":"811444e909a735b0","repo":"Netflix/Hystrix","slug":"the-timeinmilliseconds-must-divide-equally-into-nu-811444","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/HystrixRollingPercentile.java","lineNumber":126,"sourceCode":"     * @param enabled\n     *            {@code HystrixProperty<Boolean>} whether data should be tracked and percentiles calculated.\n     *            <p>\n     *            If 'false' methods will do nothing.\n     */\n    public HystrixRollingPercentile(int timeInMilliseconds, int numberOfBuckets, int bucketDataLength, HystrixProperty<Boolean> enabled) {\n        this(ACTUAL_TIME, timeInMilliseconds, numberOfBuckets, bucketDataLength, enabled);\n\n    }\n\n    /* package for testing */ HystrixRollingPercentile(Time time, int timeInMilliseconds, int numberOfBuckets, int bucketDataLength, HystrixProperty<Boolean> enabled) {\n        this.time = time;\n        this.timeInMilliseconds = timeInMilliseconds;\n        this.numberOfBuckets = numberOfBuckets;\n        this.bucketDataLength = bucketDataLength;\n        this.enabled = enabled;\n\n        if (this.timeInMilliseconds % this.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.bucketSizeInMilliseconds = this.timeInMilliseconds / this.numberOfBuckets;\n\n        buckets = new BucketCircularArray(this.numberOfBuckets);\n    }\n\n    /**\n     * Add value (or values) to current bucket.\n     * \n     * @param value\n     *            Value to be stored in current bucket such as execution latency in milliseconds\n     */\n    public void addValue(int... value) {\n        /* no-op if disabled */\n        if (!enabled.get())\n            return;\n\n        for (int v : value) {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingPercentile.java#L108-L144","documentation":"HystrixRollingPercentile - the structure behind Hystrix's latency percentiles (metrics.rollingPercentile.*) - divides its window timeInMilliseconds into numberOfBuckets and requires an exact division. If timeInMilliseconds % numberOfBuckets != 0, the constructor throws IllegalArgumentException because bucket boundaries could not be computed consistently.","triggerScenarios":"Setting hystrix.command.<key>.metrics.rollingPercentile.timeInMilliseconds and .numBuckets to an indivisible pair (e.g. 1000ms with 6 buckets is fine, 1000ms with 7 buckets throws); constructing HystrixRollingPercentile directly with such values in tests or custom metrics.","commonSituations":"Tuning percentile windows without recomputing divisibility (e.g. changing timeInMilliseconds to 7000 while leaving numBuckets=10); default-mismatch after merging config files from different projects.","solutions":["Choose an evenly divisible (timeInMilliseconds, numBuckets) pair, e.g. 60000ms/12 or 10000ms/10.","Validate the pair at application startup when both values come from external config, and fail with an explicit message.","Remember each bucket must also hold bucketDataLength samples; prefer leaving rollingPercentile defaults unless you need finer granularity."],"exampleFix":"# before\nhystrix.command.orders.metrics.rollingPercentile.timeInMilliseconds=10000\nhystrix.command.orders.metrics.rollingPercentile.numBuckets=6   # 10000 % 6 != 0\n\n# after\nhystrix.command.orders.metrics.rollingPercentile.timeInMilliseconds=12000\nhystrix.command.orders.metrics.rollingPercentile.numBuckets=6   # 2000ms buckets","handlingStrategy":"validation","validationCode":"static void checkPercentileWindow(int timeMs, int numBuckets) {\n    if (timeMs % numBuckets != 0) {\n        throw new IllegalArgumentException(\"rollingPercentile timeInMilliseconds must be divisible by numBuckets\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate hystrix...metrics.rollingPercentile.* pairs together at startup.","Prefer the defaults unless you have measured reason to change them."],"tags":["hystrix","metrics","percentiles","configuration"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}