The average ledger close time is 5.3 seconds. https://dashboard.stellar.org/ A lot of the time, the close time is identical to the previous 5 or 6 closes. But then you see a close time that is faster, or a close time that takes 10 seconds or more. What is the cause of the "sooner than I expected" close time and the "wow, that was a lot longer than expected" close time. I can't be the number of transactions since there are WAY to many examples of close times that are IDENTICAL (or appear to be identical from the graph). The reason I ask the question is for DEX trades.... I want to place my DEX trade RIGHT at ledger close time so I can incorporate the information gleaned from viewing transactions that are about to be processed but not yet posted.
Given the nature of distributed systems, we aim for 5 seconds, but in reality a wide degree of items can come up that add random variability to the close time.
Essentially all nodes are supposed to reach consensus every 5 seconds - that's a hardcoded time that is subject to change. However, a few things might come up:
- Even though every server uses NTP for keeping their clock in sync with UTC, there are occasionally times where nodes are out of sync just slightly and they cause weird overlaps when it comes to consensus. often increasing the time of a closure by a few seconds, or causing another consensus to complete right after another one.
- When network congestion happens occasionally the "leader" node isn't able to respond with the closure time or their vote within the timeframe - at this point, the network chooses a new leader to establish the close time, and this timeout can add a few seconds to the network close.
There are likely a few other cases as well, but the essential nature of the system is that it's inherently unpredictable - you're likely better aiming for the intended time (5 seconds; which we're always working towards maintaining as close to as possible) and working around the edge case of a long or short ledger close.