You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@curator.apache.org by Benjamin Jaton <be...@gmail.com> on 2016/11/01 22:03:18 UTC

What is connectionTimeoutMs?

Hello,

Is there a documentation somewhere about what connectionTimeoutMs
represents?

The only thing I could find was:
https://curator.apache.org/apidocs/org/apache/curator/framework/CuratorFrameworkFactory.html

Which simply states:
    connectionTimeoutMs - connection timeout

I am asking because it seems like we HAVE to use a connectionTimeoutMs that
is greater than the sessionTimeout, otherwise we may run into CURATOR-355
(also if that is the case, it would be nice to just enforce it or at least
log and warn/error).

Thanks,
Benjamin

Re: What is connectionTimeoutMs?

Posted by Cameron McKenzie <ca...@apache.org>.
Might have to defer to Jordan on this one.

I wonder if it is trying to handle the case where one of the ZK nodes is
dead. Under some circumstances I have seen in the past that the ZK client
did not handle this well, it just got stuck on the dead node and did not
cycle to the others. That's the only think I can think of.

On Wed, Nov 2, 2016 at 9:37 AM, Benjamin Jaton <be...@gmail.com>
wrote:

>
>
> On Tue, Nov 1, 2016 at 3:26 PM, Cameron McKenzie <ca...@apache.org>
> wrote:
>
>> hey Benjamin,
>> I've just had a quick look through the code and it seems that it's used
>> internally by Curator when establishing connections to ZK. If a connection
>> is attempted (i.e. a new Zookeeper client handle is instantiated), Curator
>> will allow up to the defined connection timeout MS amount of time to pass
>> to wait for the connection to be established. If it is not established by
>> this point in time it throws away the Zookeeper handle and tries again.
>>
>
> That is my understanding as well.
>
>
>>
>> There's actually a warning that gets generated if you attempt to
>> configure the connection timeout > session timeout. I'm not positive of why
>> this is, but I would guess that it's because in this case it would be
>> possible for the session to timeout while waiting for a connection to a
>> dead ZK node? I'm not sure how the underlying ZK handle decides how to
>> connect to a particular ZK instance (it's some sort of random load sharing
>> I think), but I have certainly seen problems when one of the hosts in the
>> ensemble cannot be reached.
>> cheers
>>
>
> connection timeout > session timeout doesn't seem to be useful indeed.
>
> But connection timeout < session timeout seems to be erroneous as well.
> The ZK API will spend seessionTimeout to go through all the nodes. So if
> the connectionTimeout is smaller, we may only try to connect to a subset of
> those nodes. I have no idea when that would be a good idea.
>
> As far as I understand, connectionTimeout has to be equal to
> sessionTimeout.
>
>
>>
>>
>>
>> On Wed, Nov 2, 2016 at 9:03 AM, Benjamin Jaton <be...@gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> Is there a documentation somewhere about what connectionTimeoutMs
>>> represents?
>>>
>>> The only thing I could find was:
>>> https://curator.apache.org/apidocs/org/apache/curator/framew
>>> ork/CuratorFrameworkFactory.html
>>>
>>> Which simply states:
>>>     connectionTimeoutMs - connection timeout
>>>
>>> I am asking because it seems like we HAVE to use a connectionTimeoutMs
>>> that is greater than the sessionTimeout, otherwise we may run into
>>> CURATOR-355 (also if that is the case, it would be nice to just enforce it
>>> or at least log and warn/error).
>>>
>>> Thanks,
>>> Benjamin
>>>
>>
>>
>

Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
Gee - I don’t know what else to say :D It’s really not clear from this thread? Honestly, I don’t know how to say it any clearer. Anyone else? Again, here’s what I wrote earlier today:

connectionTimeout is how long you’re willing to wait before the initial connection to ZK - i.e. until Curator gets SysConnected. It’s really just as simple as that. The warning occurs because Curator 3.0 now injects a “fake” session timeout if notices a lapse of the session timeout. So, if sessionTimeout is less than connectionTimeout, the sessionTimeout will always take precedence.

How you set the values is entirely up to you. When I write ZK applications I use a sessionTimeout in the 60 second or greater range. I would not want to wait 1 minute before I knew that a cluster was unavailable. Therefore, I’d use a connectionTimeout of 10 seconds and a sessionTimeout of 60.

-Jordan

> On Nov 2, 2016, at 12:00 AM, Imesha Sudasingha <im...@cse.mrt.ac.lk> wrote:
> 
> Hello all,
> 
> I was going through this thread and found out I too need a clear explanation on "what is connectionTimeout and sessionTimeout". Even though you have discussed a lot about it(which I have read), still I'm not getting a clear picture. Can someone elaborate on the it? And give a clear view of those 2 parameters and what they are for?
> 
> Thanks!
> 
> Regards,
> Imesha Sudasingha
> 
> 
> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jordan@jordanzimmerman.com <ma...@jordanzimmerman.com>> wrote:
> 
>> so if we use a connectionTimeout smaller than sessionTimeout, we may fail before having tried all the nodes.
> 
> That’s correct and up to you. That’s why these are configurable options. Use values that make sense for your applications.
> 
> -Jordan
> 
> 
> 


Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
> I can't think of a use case where that's useful.

Have a look at StandardConnectionHandlingPolicy.callWithRetry(). It waits for a positive connection or until the connection timeout has elapsed. But, IT CALLS THE METHOD ANYWAY. There are many reasons to have a small connection timeout. You could even do your own waitUntilConnected, close the Curator handle on failure and try again increasing the likelihood that ZooKeeper would try another server. It’s a tool in a toolbox. Use it how you like.

-Jordan

> On Nov 2, 2016, at 11:43 AM, Benjamin Jaton <be...@gmail.com> wrote:
> 
> Well I can do that, but I would probably recommend using connectionTimeout = sessionTimeout.
> 
> By default Curator uses:
>     private static final int DEFAULT_SESSION_TIMEOUT_MS = Integer.getInteger("curator-default-session-timeout", 60 * 1000);
>     private static final int DEFAULT_CONNECTION_TIMEOUT_MS = Integer.getInteger("curator-default-connection-timeout", 15 * 1000);
> So by default Curator will only check the first node.
> 
> I can't think of a use case where that's useful.
> 
> Regardless I can write something after I do more tests on this.
> 
> 
> 
> 
> On Wed, Nov 2, 2016 at 9:10 AM, Jordan Zimmerman <jordan@jordanzimmerman.com <ma...@jordanzimmerman.com>> wrote:
> That’s correct Benjamin. As Curator wraps the library-provided ZooKeeper class there’s nothing Curator can do about this. I’ll try to write a Tech Note about this when I can. If you don’t mind, Benjamin, maybe you could write it?
> 
> https://cwiki.apache.org/confluence/display/CURATOR/Tech+Notes <https://cwiki.apache.org/confluence/display/CURATOR/Tech+Notes>
> 
> -Jordan
> 
> 
>> On Nov 2, 2016, at 11:08 AM, Benjamin Jaton <benjamin.jaton@gmail.com <ma...@gmail.com>> wrote:
>> 
>> 
>> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if the first node that gets picked up is down it will timeout after 20 sec. So Curator would fail to connect yet the ensemble is available.
>> 
>> How can this timeout after 20 secs, if the connection timeout is 10 seconds? Also, 
>> 
>> Curator's connectionTimeout is to be understood as connection to the whole ensemble, not individual node.
>> 
>> How long do you think the ZooKeeper API will wait for a connection before trying the next node?
>> The answer is sessionTimeout / #nodes = 60 / 3 = 20 seconds.
>> 
>> 0 sec - try 1st node
>> 20 sec - try 2nd node
>> 40 sec - try 3rd node
>> 
>> Now if Curator has a cap at 10 seconds, it won't wait for the ZK API to reach the other 2 nodes.
>> 
>> Hope that's clearer.
>> 
>> Benjamin
>>  
>> 
>> So Curator would fail to connect yet the ensemble is available
>> 
>> Can you explain the  above statement then? As for my understanding, curator will try all Zookeeper nodes until it connects to an up and running zookeeper server or until the connection timeout. 
>> 
>> -Imesha 
>> 
>> On 2 November 2016 at 10:45, Cameron McKenzie <mckenzie.cam@gmail.com <ma...@gmail.com>> wrote:
>> Session timeout is a Zookeeper concept. It's just the amount of time (in MS) that a client session can be idle for before the Zookeeper server times it out.  A heart beat keeps the session alive, so the session will only time out due to network issues.
>> 
>> The connection timeout is a Curator concept. Jordan described its use in this thread. Basically, it just defines how long Curator will wait for a connection to be established to Zookeeper before giving up and trying again.
>> 
>> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <imesha.13@cse.mrt.ac.lk <ma...@cse.mrt.ac.lk>> wrote:
>> Hello all,
>> 
>> I was going through this thread and found out I too need a clear explanation on "what is connectionTimeout and sessionTimeout". Even though you have discussed a lot about it(which I have read), still I'm not getting a clear picture. Can someone elaborate on the it? And give a clear view of those 2 parameters and what they are for?
>> 
>> Thanks!
>> 
>> Regards,
>> Imesha Sudasingha
>> 
>> 
>> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jordan@jordanzimmerman.com <ma...@jordanzimmerman.com>> wrote:
>> 
>>> so if we use a connectionTimeout smaller than sessionTimeout, we may fail before having tried all the nodes.
>> 
>> That’s correct and up to you. That’s why these are configurable options. Use values that make sense for your applications.
>> 
>> -Jordan
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Imesha Sudasingha
>> Undergraduate of Department of Computer Science and  Engineering,
>> University of Moratuwa.
>> +94717086160 <tel:%2B94717086160>
>> View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>
> 
> 


Re: What is connectionTimeoutMs?

Posted by Benjamin Jaton <be...@gmail.com>.
Well I can do that, but I would probably recommend using connectionTimeout
= sessionTimeout.

By default Curator uses:
    private static final int DEFAULT_SESSION_TIMEOUT_MS =
Integer.getInteger("curator-default-session-timeout", 60 * 1000);
    private static final int DEFAULT_CONNECTION_TIMEOUT_MS =
Integer.getInteger("curator-default-connection-timeout", 15 * 1000);
So by default Curator will only check the first node.

I can't think of a use case where that's useful.

Regardless I can write something after I do more tests on this.




On Wed, Nov 2, 2016 at 9:10 AM, Jordan Zimmerman <jordan@jordanzimmerman.com
> wrote:

> That’s correct Benjamin. As Curator wraps the library-provided ZooKeeper
> class there’s nothing Curator can do about this. I’ll try to write a Tech
> Note about this when I can. If you don’t mind, Benjamin, maybe you could
> write it?
>
> https://cwiki.apache.org/confluence/display/CURATOR/Tech+Notes
>
> -Jordan
>
>
> On Nov 2, 2016, at 11:08 AM, Benjamin Jaton <be...@gmail.com>
> wrote:
>
>
> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if
>>> the first node that gets picked up is down it will timeout after 20 sec. So
>>> Curator would fail to connect yet the ensemble is available.
>>
>>
>> How can this timeout after 20 secs, if the connection timeout is 10
>> seconds? Also,
>>
>
> Curator's connectionTimeout is to be understood as connection to the whole
> ensemble, not individual node.
>
> How long do you think the ZooKeeper API will wait for a connection before
> trying the next node?
> The answer is sessionTimeout / #nodes = 60 / 3 = 20 seconds.
>
> 0 sec - try 1st node
> 20 sec - try 2nd node
> 40 sec - try 3rd node
>
> Now if Curator has a cap at 10 seconds, it won't wait for the ZK API to
> reach the other 2 nodes.
>
> Hope that's clearer.
>
> Benjamin
>
>
>>
>> So Curator would fail to connect yet the ensemble is available
>>
>>
>> Can you explain the  above statement then? As for my understanding,
>> curator will try all Zookeeper nodes until it connects to an up and running
>> zookeeper server or until the connection timeout.
>>
>> -Imesha
>>
>> On 2 November 2016 at 10:45, Cameron McKenzie <mc...@gmail.com>
>> wrote:
>>
>>> Session timeout is a Zookeeper concept. It's just the amount of time (in
>>> MS) that a client session can be idle for before the Zookeeper server times
>>> it out.  A heart beat keeps the session alive, so the session will only
>>> time out due to network issues.
>>>
>>> The connection timeout is a Curator concept. Jordan described its use in
>>> this thread. Basically, it just defines how long Curator will wait for a
>>> connection to be established to Zookeeper before giving up and trying again.
>>>
>>> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <
>>> imesha.13@cse.mrt.ac.lk> wrote:
>>>
>>>> Hello all,
>>>>
>>>> I was going through this thread and found out I too need a clear
>>>> explanation on "what is connectionTimeout and sessionTimeout". Even though
>>>> you have discussed a lot about it(which I have read), still I'm not getting
>>>> a clear picture. Can someone elaborate on the it? And give a clear view of
>>>> those 2 parameters and what they are for?
>>>>
>>>> Thanks!
>>>>
>>>> Regards,
>>>> Imesha Sudasingha
>>>>
>>>> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jo...@jordanzimmerman.com>
>>>> wrote:
>>>>
>>>>>
>>>>> so if we use a connectionTimeout smaller than sessionTimeout, we may
>>>>> fail before having tried all the nodes.
>>>>>
>>>>>
>>>>> That’s correct and up to you. That’s why these are configurable
>>>>> options. Use values that make sense for your applications.
>>>>>
>>>>> -Jordan
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>
>>
>> --
>> *Imesha Sudasingha*
>> Undergraduate of Department of Computer Science and  Engineering,
>> University of Moratuwa.
>> +94717086160
>> View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>
>>
>
>
>

Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
That’s correct Benjamin. As Curator wraps the library-provided ZooKeeper class there’s nothing Curator can do about this. I’ll try to write a Tech Note about this when I can. If you don’t mind, Benjamin, maybe you could write it?

https://cwiki.apache.org/confluence/display/CURATOR/Tech+Notes

-Jordan

> On Nov 2, 2016, at 11:08 AM, Benjamin Jaton <be...@gmail.com> wrote:
> 
> 
> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if the first node that gets picked up is down it will timeout after 20 sec. So Curator would fail to connect yet the ensemble is available.
> 
> How can this timeout after 20 secs, if the connection timeout is 10 seconds? Also, 
> 
> Curator's connectionTimeout is to be understood as connection to the whole ensemble, not individual node.
> 
> How long do you think the ZooKeeper API will wait for a connection before trying the next node?
> The answer is sessionTimeout / #nodes = 60 / 3 = 20 seconds.
> 
> 0 sec - try 1st node
> 20 sec - try 2nd node
> 40 sec - try 3rd node
> 
> Now if Curator has a cap at 10 seconds, it won't wait for the ZK API to reach the other 2 nodes.
> 
> Hope that's clearer.
> 
> Benjamin
>  
> 
> So Curator would fail to connect yet the ensemble is available
> 
> Can you explain the  above statement then? As for my understanding, curator will try all Zookeeper nodes until it connects to an up and running zookeeper server or until the connection timeout. 
> 
> -Imesha 
> 
> On 2 November 2016 at 10:45, Cameron McKenzie <mckenzie.cam@gmail.com <ma...@gmail.com>> wrote:
> Session timeout is a Zookeeper concept. It's just the amount of time (in MS) that a client session can be idle for before the Zookeeper server times it out.  A heart beat keeps the session alive, so the session will only time out due to network issues.
> 
> The connection timeout is a Curator concept. Jordan described its use in this thread. Basically, it just defines how long Curator will wait for a connection to be established to Zookeeper before giving up and trying again.
> 
> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <imesha.13@cse.mrt.ac.lk <ma...@cse.mrt.ac.lk>> wrote:
> Hello all,
> 
> I was going through this thread and found out I too need a clear explanation on "what is connectionTimeout and sessionTimeout". Even though you have discussed a lot about it(which I have read), still I'm not getting a clear picture. Can someone elaborate on the it? And give a clear view of those 2 parameters and what they are for?
> 
> Thanks!
> 
> Regards,
> Imesha Sudasingha
> 
> 
> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jordan@jordanzimmerman.com <ma...@jordanzimmerman.com>> wrote:
> 
>> so if we use a connectionTimeout smaller than sessionTimeout, we may fail before having tried all the nodes.
> 
> That’s correct and up to you. That’s why these are configurable options. Use values that make sense for your applications.
> 
> -Jordan
> 
> 
> 
> 
> 
> 
> 
> -- 
> Imesha Sudasingha
> Undergraduate of Department of Computer Science and  Engineering,
> University of Moratuwa.
> +94717086160 <tel:%2B94717086160>
> View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>


Re: What is connectionTimeoutMs?

Posted by Benjamin Jaton <be...@gmail.com>.
> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if
>> the first node that gets picked up is down it will timeout after 20 sec. So
>> Curator would fail to connect yet the ensemble is available.
>
>
> How can this timeout after 20 secs, if the connection timeout is 10
> seconds? Also,
>

Curator's connectionTimeout is to be understood as connection to the whole
ensemble, not individual node.

How long do you think the ZooKeeper API will wait for a connection before
trying the next node?
The answer is sessionTimeout / #nodes = 60 / 3 = 20 seconds.

0 sec - try 1st node
20 sec - try 2nd node
40 sec - try 3rd node

Now if Curator has a cap at 10 seconds, it won't wait for the ZK API to
reach the other 2 nodes.

Hope that's clearer.

Benjamin


>
> So Curator would fail to connect yet the ensemble is available
>
>
> Can you explain the  above statement then? As for my understanding,
> curator will try all Zookeeper nodes until it connects to an up and running
> zookeeper server or until the connection timeout.
>
> -Imesha
>
> On 2 November 2016 at 10:45, Cameron McKenzie <mc...@gmail.com>
> wrote:
>
>> Session timeout is a Zookeeper concept. It's just the amount of time (in
>> MS) that a client session can be idle for before the Zookeeper server times
>> it out.  A heart beat keeps the session alive, so the session will only
>> time out due to network issues.
>>
>> The connection timeout is a Curator concept. Jordan described its use in
>> this thread. Basically, it just defines how long Curator will wait for a
>> connection to be established to Zookeeper before giving up and trying again.
>>
>> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <
>> imesha.13@cse.mrt.ac.lk> wrote:
>>
>>> Hello all,
>>>
>>> I was going through this thread and found out I too need a clear
>>> explanation on "what is connectionTimeout and sessionTimeout". Even though
>>> you have discussed a lot about it(which I have read), still I'm not getting
>>> a clear picture. Can someone elaborate on the it? And give a clear view of
>>> those 2 parameters and what they are for?
>>>
>>> Thanks!
>>>
>>> Regards,
>>> Imesha Sudasingha
>>>
>>> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jo...@jordanzimmerman.com>
>>> wrote:
>>>
>>>>
>>>> so if we use a connectionTimeout smaller than sessionTimeout, we may
>>>> fail before having tried all the nodes.
>>>>
>>>>
>>>> That’s correct and up to you. That’s why these are configurable
>>>> options. Use values that make sense for your applications.
>>>>
>>>> -Jordan
>>>>
>>>>
>>>>
>>>>
>>
>
>
> --
> *Imesha Sudasingha*
> Undergraduate of Department of Computer Science and  Engineering,
> University of Moratuwa.
> +94717086160
> View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>
>

Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
That’s what Benjamin wrote - it doesn’t make sense to me either. 

> On Nov 2, 2016, at 7:00 AM, Imesha Sudasingha <im...@cse.mrt.ac.lk> wrote:
> 
> I understand those 2 points. I was confused with the following comment.
>  
> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if the first node that gets picked up is down it will timeout after 20 sec. So Curator would fail to connect yet the ensemble is available.
> 
> How can this timeout after 20 secs, if the connection timeout is 10 seconds? Also, 
> 
> So Curator would fail to connect yet the ensemble is available
> 
> Can you explain the  above statement then? As for my understanding, curator will try all Zookeeper nodes until it connects to an up and running zookeeper server or until the connection timeout. 
> 
> -Imesha 
> 
> On 2 November 2016 at 10:45, Cameron McKenzie <mckenzie.cam@gmail.com <ma...@gmail.com>> wrote:
> Session timeout is a Zookeeper concept. It's just the amount of time (in MS) that a client session can be idle for before the Zookeeper server times it out.  A heart beat keeps the session alive, so the session will only time out due to network issues.
> 
> The connection timeout is a Curator concept. Jordan described its use in this thread. Basically, it just defines how long Curator will wait for a connection to be established to Zookeeper before giving up and trying again.
> 
> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <imesha.13@cse.mrt.ac.lk <ma...@cse.mrt.ac.lk>> wrote:
> Hello all,
> 
> I was going through this thread and found out I too need a clear explanation on "what is connectionTimeout and sessionTimeout". Even though you have discussed a lot about it(which I have read), still I'm not getting a clear picture. Can someone elaborate on the it? And give a clear view of those 2 parameters and what they are for?
> 
> Thanks!
> 
> Regards,
> Imesha Sudasingha
> 
> 
> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jordan@jordanzimmerman.com <ma...@jordanzimmerman.com>> wrote:
> 
>> so if we use a connectionTimeout smaller than sessionTimeout, we may fail before having tried all the nodes.
> 
> That’s correct and up to you. That’s why these are configurable options. Use values that make sense for your applications.
> 
> -Jordan
> 
> 
> 
> 
> 
> 
> 
> -- 
> Imesha Sudasingha
> Undergraduate of Department of Computer Science and  Engineering,
> University of Moratuwa.
> +94717086160
> View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>

Re: What is connectionTimeoutMs?

Posted by Imesha Sudasingha <im...@cse.mrt.ac.lk>.
I understand those 2 points. I was confused with the following comment.


> In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if
> the first node that gets picked up is down it will timeout after 20 sec. So
> Curator would fail to connect yet the ensemble is available.


How can this timeout after 20 secs, if the connection timeout is 10
seconds? Also,

So Curator would fail to connect yet the ensemble is available


Can you explain the  above statement then? As for my understanding, curator
will try all Zookeeper nodes until it connects to an up and running
zookeeper server or until the connection timeout.

-Imesha

On 2 November 2016 at 10:45, Cameron McKenzie <mc...@gmail.com>
wrote:

> Session timeout is a Zookeeper concept. It's just the amount of time (in
> MS) that a client session can be idle for before the Zookeeper server times
> it out.  A heart beat keeps the session alive, so the session will only
> time out due to network issues.
>
> The connection timeout is a Curator concept. Jordan described its use in
> this thread. Basically, it just defines how long Curator will wait for a
> connection to be established to Zookeeper before giving up and trying again.
>
> On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <imesha.13@cse.mrt.ac.lk
> > wrote:
>
>> Hello all,
>>
>> I was going through this thread and found out I too need a clear
>> explanation on "what is connectionTimeout and sessionTimeout". Even though
>> you have discussed a lot about it(which I have read), still I'm not getting
>> a clear picture. Can someone elaborate on the it? And give a clear view of
>> those 2 parameters and what they are for?
>>
>> Thanks!
>>
>> Regards,
>> Imesha Sudasingha
>>
>> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jo...@jordanzimmerman.com>
>> wrote:
>>
>>>
>>> so if we use a connectionTimeout smaller than sessionTimeout, we may
>>> fail before having tried all the nodes.
>>>
>>>
>>> That’s correct and up to you. That’s why these are configurable options.
>>> Use values that make sense for your applications.
>>>
>>> -Jordan
>>>
>>>
>>>
>>>
>


-- 
*Imesha Sudasingha*
Undergraduate of Department of Computer Science and  Engineering,
University of Moratuwa.
+94717086160
View in Linkedin <https://lk.linkedin.com/in/imeshasudasingha>

Re: What is connectionTimeoutMs?

Posted by Cameron McKenzie <mc...@gmail.com>.
Session timeout is a Zookeeper concept. It's just the amount of time (in
MS) that a client session can be idle for before the Zookeeper server times
it out.  A heart beat keeps the session alive, so the session will only
time out due to network issues.

The connection timeout is a Curator concept. Jordan described its use in
this thread. Basically, it just defines how long Curator will wait for a
connection to be established to Zookeeper before giving up and trying again.

On Wed, Nov 2, 2016 at 4:00 PM, Imesha Sudasingha <im...@cse.mrt.ac.lk>
wrote:

> Hello all,
>
> I was going through this thread and found out I too need a clear
> explanation on "what is connectionTimeout and sessionTimeout". Even though
> you have discussed a lot about it(which I have read), still I'm not getting
> a clear picture. Can someone elaborate on the it? And give a clear view of
> those 2 parameters and what they are for?
>
> Thanks!
>
> Regards,
> Imesha Sudasingha
>
> On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jo...@jordanzimmerman.com>
> wrote:
>
>>
>> so if we use a connectionTimeout smaller than sessionTimeout, we may fail
>> before having tried all the nodes.
>>
>>
>> That’s correct and up to you. That’s why these are configurable options.
>> Use values that make sense for your applications.
>>
>> -Jordan
>>
>>
>>
>>

Re: What is connectionTimeoutMs?

Posted by Imesha Sudasingha <im...@cse.mrt.ac.lk>.
Hello all,

I was going through this thread and found out I too need a clear
explanation on "what is connectionTimeout and sessionTimeout". Even though
you have discussed a lot about it(which I have read), still I'm not getting
a clear picture. Can someone elaborate on the it? And give a clear view of
those 2 parameters and what they are for?

Thanks!

Regards,
Imesha Sudasingha

On Nov 2, 2016 4:26 AM, "Jordan Zimmerman" <jo...@jordanzimmerman.com>
wrote:

>
> so if we use a connectionTimeout smaller than sessionTimeout, we may fail
> before having tried all the nodes.
>
>
> That’s correct and up to you. That’s why these are configurable options.
> Use values that make sense for your applications.
>
> -Jordan
>
>
>
>

Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
> so if we use a connectionTimeout smaller than sessionTimeout, we may fail before having tried all the nodes.

That’s correct and up to you. That’s why these are configurable options. Use values that make sense for your applications.

-Jordan




Re: What is connectionTimeoutMs?

Posted by Benjamin Jaton <be...@gmail.com>.
The ZK API might take up to <sessionTimeout> to try all the nodes, so if we
use a connectionTimeout smaller than sessionTimeout, we may fail before
having tried all the nodes.

In your example (conenctionTimeout = 10, sessionTimeout = 60, 3 nodes), if
the first node that gets picked up is down it will timeout after 20 sec. So
Curator would fail to connect yet the ensemble is available.

(Note that if you test this locally with TestingServers, you may not
reproduce the issue because the sockets timeout instantly.)

On Tue, Nov 1, 2016 at 3:47 PM, Jordan Zimmerman <jordan@jordanzimmerman.com
> wrote:

> connectionTimeout is how long you’re willing to wait before the initial
> connection to ZK - i.e. until Curator gets SysConnected. It’s really just
> as simple as that. The warning occurs because Curator 3.0 now injects a
> “fake” session timeout if notices a lapse of the session timeout. So, if
> sessionTimeout is less than connectionTimeout, the sessionTimeout will
> always take precedence.
>
> How you set the values is entirely up to you. When I write ZK applications
> I use a sessionTimeout in the 60 second or greater range. I would not want
> to wait 1 minute before I knew that a cluster was unavailable. Therefore,
> I’d use a connectionTimeout of 10 seconds and a sessionTimeout of 60.
>
> -JZ
>
>
> On Nov 1, 2016, at 5:37 PM, Benjamin Jaton <be...@gmail.com>
> wrote:
>
>
>
> On Tue, Nov 1, 2016 at 3:26 PM, Cameron McKenzie <ca...@apache.org>
> wrote:
>
>> hey Benjamin,
>> I've just had a quick look through the code and it seems that it's used
>> internally by Curator when establishing connections to ZK. If a connection
>> is attempted (i.e. a new Zookeeper client handle is instantiated), Curator
>> will allow up to the defined connection timeout MS amount of time to pass
>> to wait for the connection to be established. If it is not established by
>> this point in time it throws away the Zookeeper handle and tries again.
>>
>
> That is my understanding as well.
>
>
>>
>> There's actually a warning that gets generated if you attempt to
>> configure the connection timeout > session timeout. I'm not positive of why
>> this is, but I would guess that it's because in this case it would be
>> possible for the session to timeout while waiting for a connection to a
>> dead ZK node? I'm not sure how the underlying ZK handle decides how to
>> connect to a particular ZK instance (it's some sort of random load sharing
>> I think), but I have certainly seen problems when one of the hosts in the
>> ensemble cannot be reached.
>> cheers
>>
>
> connection timeout > session timeout doesn't seem to be useful indeed.
>
> But connection timeout < session timeout seems to be erroneous as well.
> The ZK API will spend seessionTimeout to go through all the nodes. So if
> the connectionTimeout is smaller, we may only try to connect to a subset of
> those nodes. I have no idea when that would be a good idea.
>
> As far as I understand, connectionTimeout has to be equal to
> sessionTimeout.
>
>
>>
>>
>>
>> On Wed, Nov 2, 2016 at 9:03 AM, Benjamin Jaton <be...@gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> Is there a documentation somewhere about what connectionTimeoutMs
>>> represents?
>>>
>>> The only thing I could find was:
>>> https://curator.apache.org/apidocs/org/apache/curator/framew
>>> ork/CuratorFrameworkFactory.html
>>>
>>> Which simply states:
>>>     connectionTimeoutMs - connection timeout
>>>
>>> I am asking because it seems like we HAVE to use a connectionTimeoutMs
>>> that is greater than the sessionTimeout, otherwise we may run into
>>> CURATOR-355 (also if that is the case, it would be nice to just enforce it
>>> or at least log and warn/error).
>>>
>>> Thanks,
>>> Benjamin
>>>
>>
>>
>
>

Re: What is connectionTimeoutMs?

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
connectionTimeout is how long you’re willing to wait before the initial connection to ZK - i.e. until Curator gets SysConnected. It’s really just as simple as that. The warning occurs because Curator 3.0 now injects a “fake” session timeout if notices a lapse of the session timeout. So, if sessionTimeout is less than connectionTimeout, the sessionTimeout will always take precedence.

How you set the values is entirely up to you. When I write ZK applications I use a sessionTimeout in the 60 second or greater range. I would not want to wait 1 minute before I knew that a cluster was unavailable. Therefore, I’d use a connectionTimeout of 10 seconds and a sessionTimeout of 60.

-JZ

> On Nov 1, 2016, at 5:37 PM, Benjamin Jaton <be...@gmail.com> wrote:
> 
> 
> 
> On Tue, Nov 1, 2016 at 3:26 PM, Cameron McKenzie <cammckenzie@apache.org <ma...@apache.org>> wrote:
> hey Benjamin,
> I've just had a quick look through the code and it seems that it's used internally by Curator when establishing connections to ZK. If a connection is attempted (i.e. a new Zookeeper client handle is instantiated), Curator will allow up to the defined connection timeout MS amount of time to pass to wait for the connection to be established. If it is not established by this point in time it throws away the Zookeeper handle and tries again.
> 
> That is my understanding as well.
>  
> 
> There's actually a warning that gets generated if you attempt to configure the connection timeout > session timeout. I'm not positive of why this is, but I would guess that it's because in this case it would be possible for the session to timeout while waiting for a connection to a dead ZK node? I'm not sure how the underlying ZK handle decides how to connect to a particular ZK instance (it's some sort of random load sharing I think), but I have certainly seen problems when one of the hosts in the ensemble cannot be reached.
> cheers
> 
> connection timeout > session timeout doesn't seem to be useful indeed.
> 
> But connection timeout < session timeout seems to be erroneous as well. The ZK API will spend seessionTimeout to go through all the nodes. So if the connectionTimeout is smaller, we may only try to connect to a subset of those nodes. I have no idea when that would be a good idea.
> 
> As far as I understand, connectionTimeout has to be equal to sessionTimeout.
>  
> 
> 
> 
> On Wed, Nov 2, 2016 at 9:03 AM, Benjamin Jaton <benjamin.jaton@gmail.com <ma...@gmail.com>> wrote:
> Hello,
> 
> Is there a documentation somewhere about what connectionTimeoutMs represents?
> 
> The only thing I could find was:
> https://curator.apache.org/apidocs/org/apache/curator/framework/CuratorFrameworkFactory.html <https://curator.apache.org/apidocs/org/apache/curator/framework/CuratorFrameworkFactory.html>
> 
> Which simply states:
>     connectionTimeoutMs - connection timeout
> 
> I am asking because it seems like we HAVE to use a connectionTimeoutMs that is greater than the sessionTimeout, otherwise we may run into CURATOR-355 (also if that is the case, it would be nice to just enforce it or at least log and warn/error).
> 
> Thanks,
> Benjamin
> 
> 


Re: What is connectionTimeoutMs?

Posted by Benjamin Jaton <be...@gmail.com>.
On Tue, Nov 1, 2016 at 3:26 PM, Cameron McKenzie <ca...@apache.org>
wrote:

> hey Benjamin,
> I've just had a quick look through the code and it seems that it's used
> internally by Curator when establishing connections to ZK. If a connection
> is attempted (i.e. a new Zookeeper client handle is instantiated), Curator
> will allow up to the defined connection timeout MS amount of time to pass
> to wait for the connection to be established. If it is not established by
> this point in time it throws away the Zookeeper handle and tries again.
>

That is my understanding as well.


>
> There's actually a warning that gets generated if you attempt to configure
> the connection timeout > session timeout. I'm not positive of why this is,
> but I would guess that it's because in this case it would be possible for
> the session to timeout while waiting for a connection to a dead ZK node?
> I'm not sure how the underlying ZK handle decides how to connect to a
> particular ZK instance (it's some sort of random load sharing I think), but
> I have certainly seen problems when one of the hosts in the ensemble cannot
> be reached.
> cheers
>

connection timeout > session timeout doesn't seem to be useful indeed.

But connection timeout < session timeout seems to be erroneous as well. The
ZK API will spend seessionTimeout to go through all the nodes. So if the
connectionTimeout is smaller, we may only try to connect to a subset of
those nodes. I have no idea when that would be a good idea.

As far as I understand, connectionTimeout has to be equal to sessionTimeout.


>
>
>
> On Wed, Nov 2, 2016 at 9:03 AM, Benjamin Jaton <be...@gmail.com>
> wrote:
>
>> Hello,
>>
>> Is there a documentation somewhere about what connectionTimeoutMs
>> represents?
>>
>> The only thing I could find was:
>> https://curator.apache.org/apidocs/org/apache/curator/framew
>> ork/CuratorFrameworkFactory.html
>>
>> Which simply states:
>>     connectionTimeoutMs - connection timeout
>>
>> I am asking because it seems like we HAVE to use a connectionTimeoutMs
>> that is greater than the sessionTimeout, otherwise we may run into
>> CURATOR-355 (also if that is the case, it would be nice to just enforce it
>> or at least log and warn/error).
>>
>> Thanks,
>> Benjamin
>>
>
>

Re: What is connectionTimeoutMs?

Posted by Cameron McKenzie <ca...@apache.org>.
hey Benjamin,
I've just had a quick look through the code and it seems that it's used
internally by Curator when establishing connections to ZK. If a connection
is attempted (i.e. a new Zookeeper client handle is instantiated), Curator
will allow up to the defined connection timeout MS amount of time to pass
to wait for the connection to be established. If it is not established by
this point in time it throws away the Zookeeper handle and tries again.

There's actually a warning that gets generated if you attempt to configure
the connection timeout > session timeout. I'm not positive of why this is,
but I would guess that it's because in this case it would be possible for
the session to timeout while waiting for a connection to a dead ZK node?
I'm not sure how the underlying ZK handle decides how to connect to a
particular ZK instance (it's some sort of random load sharing I think), but
I have certainly seen problems when one of the hosts in the ensemble cannot
be reached.
cheers



On Wed, Nov 2, 2016 at 9:03 AM, Benjamin Jaton <be...@gmail.com>
wrote:

> Hello,
>
> Is there a documentation somewhere about what connectionTimeoutMs
> represents?
>
> The only thing I could find was:
> https://curator.apache.org/apidocs/org/apache/curator/framework/
> CuratorFrameworkFactory.html
>
> Which simply states:
>     connectionTimeoutMs - connection timeout
>
> I am asking because it seems like we HAVE to use a connectionTimeoutMs
> that is greater than the sessionTimeout, otherwise we may run into
> CURATOR-355 (also if that is the case, it would be nice to just enforce it
> or at least log and warn/error).
>
> Thanks,
> Benjamin
>