HickariCP docs say:

HikariCP relies heavily on accurate high-resolution timers for both performance and reliability. It is imperative that your server is synchronized with a time-source such as an NTP server. Especially if your server is running within a virtual machine. Do not rely on hypervisor settings to "synchronize" the clock of the virtual machine. Configure time-source synchronization inside the virtual machine. If you come asking for support on an issue that turns out to be caused by lack time synchronization, you will be taunted publicly on Twitter.

Which other connection pooling libraries would you choose, which are less sensitive to virtual machine time drifts?

1 Answer 1


Any pool in an environment in which time can flow backwards or leap forwards, which it can in a virtual machine, is going to be subject to spurious failure when it does so.

Moreover, it is not just connection pools that are affected.


  • Timed waits
  • Timed polls from a concurrent collection
  • Object.wait() with a timeout
  • Thread.sleep() call
  • ...
  • Anything in Java that requires the measurment of time is affected.

If you cannot nail down your clock drift, you will encounter unexplained application failures, occurring in your code and third-party libraries.

HikariCP (i.e.me) got sick of spending hours trouble-shooting a user's issue, reading logs and thread dumps, only to discover their clock had jumped backwards or forwards more than a minute.

User: "Why did I get a bunch of connection timeouts?!"

(several days of back-and-forth questions and examining logs later...)

HikariCP: "Well, you asked the pool to try for 30 seconds to give you a connection ... then your clock jumped forward 42 seconds and Java (and the OS) unparked all the threads as if time had really passed."

It is really simple to fix, just configure NTP inside your VM.

  • Thanks. This requires the virtual infrastructure admin to provide you with an NTP service though.
    – matanox
    Apr 15, 2017 at 5:30
  • 2
    If your outbound access is blocked,yes. Otherwise, there are hundreds of public NTP servers. But nearly all infrastructure providers have NTP service. See docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html
    – brettw
    Apr 16, 2017 at 5:51
  • Yep, but lots of code runs on-premise in segregated environments. I'm sure they have NTP services running in most those places of course.
    – matanox
    Apr 16, 2017 at 6:23
  • I couldn't find info on how much accuracy is expected. Also, do you use nanoTime for measuring (at least some) durations or is that completely configurable? Mar 11, 2020 at 15:13
  • 3
    @JurajMartinka To be clear, like most Java code, HikariCP relies on the behavior of Java APIs, such as LockSupport.parkNanos() or collection poll() methods with timeouts. What time measurement mechanism the JVM uses under the covers should be considered opaque. In general, accuracy on the order of seconds is expected. However, retrograde time movement in excess of 128ms, as per NTP spec., will provoke HikariCP to log a complaint, and evict and reestablish connections.
    – brettw
    Mar 12, 2020 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.