> @@ -126,6 +127,9 @@ public void imposeBackoffExponentialDelay(long period, > int pow, int failureCount > public void imposeBackoffExponentialDelay(long period, long maxPeriod, > int pow, int failureCount, int max, > String commandDescription) { > long delayMs = (long) (period * Math.pow(failureCount, pow)); > + // Add random delay to avoid thundering herd problem when multiple > + // simultaneous failed requests retry after sleeping for the same > delay. > + delayMs += new Random().nextInt((int) (delayMs / 10));
```delayMs``` defaults to a small value, 50 ms, although scales up to 500 ms. 10% jitter may be suboptimal; I chose this value to agree with our existing tests. Java 6 Javadoc does not guarantee thread-safety: http://docs.oracle.com/javase/6/docs/api/java/util/Random.html Although StackOverflow and the Java bug tracker suggest that it is: http://stackoverflow.com/questions/5819638/is-random-class-thread-safe http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6362070 Prefer to keep this simple if possible since we only see this on the uncommon failure path. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/286/files#r9637620