Replica set: electionTimeoutMillis vs heartbeatTimeoutSecs

681 views
Skip to first unread message

HubertBubert

unread,
Jan 19, 2016, 5:51:54 PM1/19/16
to mongodb-user
Hello,

I have a hard time trying to understand relation between these two.

heartbeatTimeoutSecs is the numer of seconds member waits for a hearbeat from other server.

electionTimeoutMillis is the time limit for detecting that the primary server is unavailable.

So let's say we set values as follows:
- heartbeatTimeoutSecs 10
- electionTimeoutMillis 5000  (we just want to reduce failover time, and this parameter should do the trick)

heartbeatTimeoutSecs value means that member is inaccesible after 10 seconds of waiting. So if member waits for 7 s for a heartbeat from primary that means 

primary is still accesible. So there is no reason for election. But on the other hand we have electionTimeoutMillis which means that after 5s primary is considered unavailable.

So:
is electionTimeoutMillis some kind of heartbeatTimeoutSecs only for primary? In other words, does electionTimeoutMillis overwrite heartbeatTimeoutSecs for primary?

cheers,
Hubert

Asya Kamsky

unread,
Jan 19, 2016, 9:42:13 PM1/19/16
to mongodb-user
Where did you find "heartbeatTimeoutSecs is the numer of seconds member waits for a hearbeat from other server"?  

The docs say: "Internal use only.  The frequency in milliseconds of the heartbeats."

Asya


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/7d2534ea-be8d-4c33-96c3-209714cf677b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
Free MongoDB Monitoring - cloud.mongodb.com
Free Online Education - university.mongodb.com
Get Involved - mongodb.org/community
We're Hiring! - https://www.mongodb.com/careers

Asya Kamsky

unread,
Jan 19, 2016, 9:49:24 PM1/19/16
to mongodb-user
Ooops, sorry, cut and paste the wrong line from the docs!

heartbeatTimeoutSecs Number of seconds that the replica set members wait for a successful heartbeat from each other. 

Think of heartbeat timeout as "how long do I wait after sending a heartbeat before I decide it's not coming back".

It applies to each heartbeat, and then failed heartbeats trigger other events, including whether an election may be needed.

So it's not really a heartbeat timeout for primaries, it's a separate _additional_ parameter applying to elections in particular.

Asya

HubertBubert

unread,
Jan 20, 2016, 6:36:58 AM1/20/16
to mongodb-user
I found it here:


The explanation you gave is for parameter: settings.heartbeatIntervalMillisThe, but the question is about settings.heartbeatTimeoutSecs.

Hubert

HubertBubert

unread,
Jan 20, 2016, 6:50:13 AM1/20/16
to mongodb-user
Ooops, sorry, answered to quickly to your first question.

Back to the topic.

I think exactly the same as you. Before 3.2 only hearbeatTimeoutSecs was available. So every member was incaccesible after this time, including master. So lets say election was triggered after this time.

Now we have electionTimeoutMillis and election will be triggered after this time as documentation says. 
Is the electionTimeoutMillis more important and have higher priority? What happens when these two properties have different values?

thank you,
Hubert

Henrik Ingo

unread,
Jan 20, 2016, 8:25:53 AM1/20/16
to mongod...@googlegroups.com
Hi Hubert

electionTimeoutMillis is used in MongoDB 3.2, when you use replication
protocol v1 (the default for new installations). As far as I
understand, this is the only setting that impacts how long servers
will wait before failover/election is started.

heartbeatTimeoutSecs was used in replication protocol v0.

Note that rs.config() still holds config values for both protocol
versions, so you can change back and forth if needed.

henrik
> https://groups.google.com/d/msgid/mongodb-user/5ed12911-343d-4263-9a8c-9dd14a64f0c8%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
henri...@avoinelama.fi
+358-40-5697354 skype: henrik.ingo irc: hingo
www.openlife.cc

My LinkedIn profile: http://fi.linkedin.com/pub/henrik-ingo/3/232/8a7

HubertBubert

unread,
Jan 20, 2016, 12:14:17 PM1/20/16
to mongodb-user, henri...@avoinelama.fi
Hello henrik,

I think I don't agree with this statement:
"heartbeatTimeoutSecs was used in replication protocol v0"

I think it is still valid in protocol version 1. At least documentetion does not say a word that this is not used in version 1. So I think it is still used. 
And this makes sense. Becouse there must be a time limit for waiting for hearbeat from another member. And this is the limit.

thank you,
Hubert

Eric Milkie

unread,
Jan 20, 2016, 2:13:14 PM1/20/16
to mongodb-user
Hi Hubert,
The heartbeatTimeoutSecs is still "valid" in protocol version 1, but it has lost its use as a way to control failover sensitivity.  I can't think of a reason to change the parameter in pv1.  Henric is correct in that the only knob that controls failover sensitivity in pv1 is electionTimeoutMillis.
Hope that helps!
-Eric

Henrik Ingo

unread,
Jan 21, 2016, 12:27:22 AM1/21/16
to mongod...@googlegroups.com


On 20 Jan 2016 19:14, "HubertBubert" <hly...@gmail.com> wrote:
> And this makes sense. Becouse there must be a time limit for waiting for hearbeat from another member. And this is the limit.
>

There must be a limit, and this is exactly what electionTimeoutMillis does.

I should also note the improved predictability of protocol version v1. In prior versions of Mongodb, there were many different timeouts to trigger failover. (Not all of them configurable.) In v1, you can expect the timeout to be at most electionTimeoutMillis.

Henrik

HubertBubert

unread,
Jan 21, 2016, 2:06:26 PM1/21/16
to mongodb-user, henri...@avoinelama.fi
Hello,

Thank you all for help.

best regards,
Hubert
Reply all
Reply to author
Forward
0 new messages