You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Jens Rantil <je...@tink.se> on 2016/02/08 15:45:39 UTC

Session timeout and heartbeat interval

Hi,

I am trying to wrap my head around the difference between "
session.timeout.ms" and "heartbeat.interval.ms". Clearly they are somewhat
tied to the same logic since heartbeat value should be less than 1/3 of the
session timeout.

Let me add some specific questions:

   - Will a session be considered "dead" if it hasn't received a heartbeat
   within "session.timeout.ms"? In that case giving 2*heartbeat as slack
   for missed heartbeats seem like a LOT of slack. Given the default values, a
   client will have 27 seconds(!) to be able to send a second heartbeat.
   - Why can't session timeout simply be based on heartbeat interval?

Could anyone clarify this a bit? Also, if you are writing a new consumer,
what is your reasoning when setting these two value?

Thanks,
Jens


-- 
Jens Rantil
Backend engineer
Tink AB

Email: jens.rantil@tink.se
Phone: +46 708 84 18 32
Web: www.tink.se

Facebook <https://www.facebook.com/#!/tink.se> Linkedin
<http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary>
 Twitter <https://twitter.com/tink>

Re: Session timeout and heartbeat interval

Posted by Jason Gustafson <ja...@confluent.io>.
Hey Jens,

The heartbeat response is used by the coordinator to tell group members
that the group needs to rebalance. For example, if a new member joins the
consumer group, then the coordinator will wait for the heartbeat from each
member and set a REBALANCE_NEEDED error code in the response. Hence the
approximate time to rebalance depends on the heartbeat interval. This is
why we have set it fairly low by default. We actually had the interval
based on the session timeout initially (we set it to 1/3 of the session
timeout), but during development, it seemed like a good idea to give users
more control over the rebalance overhead by controlling the heartbeat
interval. For example, if you need to set the session timeout to 120
seconds, you might not be too thrilled to have your best-case rebalance
time of about 40 seconds.

-Jason

On Mon, Feb 8, 2016 at 7:49 AM, Jens Rantil <je...@tink.se> wrote:

> Hi again,
>
> A somewhat related question is also how the heartbeat interval and session
> timeout relates to the poll timeout. Must the poll timeout always be lower
> than the heartbeat interval?
>
> Cheers,
> Jens
>
> On Monday, February 8, 2016, Jens Rantil <je...@tink.se> wrote:
>
> > Hi,
> >
> > I am trying to wrap my head around the difference between "
> > session.timeout.ms" and "heartbeat.interval.ms". Clearly they are
> > somewhat tied to the same logic since heartbeat value should be less than
> > 1/3 of the session timeout.
> >
> > Let me add some specific questions:
> >
> >    - Will a session be considered "dead" if it hasn't received a
> >    heartbeat within "session.timeout.ms"? In that case giving
> 2*heartbeat
> >    as slack for missed heartbeats seem like a LOT of slack. Given the
> default
> >    values, a client will have 27 seconds(!) to be able to send a second
> >    heartbeat.
> >    - Why can't session timeout simply be based on heartbeat interval?
> >
> > Could anyone clarify this a bit? Also, if you are writing a new consumer,
> > what is your reasoning when setting these two value?
> >
> > Thanks,
> > Jens
> >
> >
> > --
> > Jens Rantil
> > Backend engineer
> > Tink AB
> >
> > Email: jens.rantil@tink.se
> > <javascript:_e(%7B%7D,'cvml','jens.rantil@tink.se');>
> > Phone: +46 708 84 18 32
> > Web: www.tink.se
> >
> > Facebook <https://www.facebook.com/#!/tink.se> Linkedin
> > <
> http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary
> >
> >  Twitter <https://twitter.com/tink>
> >
> >
>
> --
> Jens Rantil
> Backend engineer
> Tink AB
>
> Email: jens.rantil@tink.se
> Phone: +46 708 84 18 32
> Web: www.tink.se
>
> Facebook <https://www.facebook.com/#!/tink.se> Linkedin
> <
> http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary
> >
>  Twitter <https://twitter.com/tink>
>

Re: Session timeout and heartbeat interval

Posted by Jens Rantil <je...@tink.se>.
Hi again,

A somewhat related question is also how the heartbeat interval and session
timeout relates to the poll timeout. Must the poll timeout always be lower
than the heartbeat interval?

Cheers,
Jens

On Monday, February 8, 2016, Jens Rantil <je...@tink.se> wrote:

> Hi,
>
> I am trying to wrap my head around the difference between "
> session.timeout.ms" and "heartbeat.interval.ms". Clearly they are
> somewhat tied to the same logic since heartbeat value should be less than
> 1/3 of the session timeout.
>
> Let me add some specific questions:
>
>    - Will a session be considered "dead" if it hasn't received a
>    heartbeat within "session.timeout.ms"? In that case giving 2*heartbeat
>    as slack for missed heartbeats seem like a LOT of slack. Given the default
>    values, a client will have 27 seconds(!) to be able to send a second
>    heartbeat.
>    - Why can't session timeout simply be based on heartbeat interval?
>
> Could anyone clarify this a bit? Also, if you are writing a new consumer,
> what is your reasoning when setting these two value?
>
> Thanks,
> Jens
>
>
> --
> Jens Rantil
> Backend engineer
> Tink AB
>
> Email: jens.rantil@tink.se
> <javascript:_e(%7B%7D,'cvml','jens.rantil@tink.se');>
> Phone: +46 708 84 18 32
> Web: www.tink.se
>
> Facebook <https://www.facebook.com/#!/tink.se> Linkedin
> <http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary>
>  Twitter <https://twitter.com/tink>
>
>

-- 
Jens Rantil
Backend engineer
Tink AB

Email: jens.rantil@tink.se
Phone: +46 708 84 18 32
Web: www.tink.se

Facebook <https://www.facebook.com/#!/tink.se> Linkedin
<http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary>
 Twitter <https://twitter.com/tink>