CTS Connectionpool

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CTS Connectionpool

Vincent Koldenhof-2
Hi all,

Is there a reason why the number of connection in the connectionpool to the CTS needs to be a valid power of 2?
During testing I have set the maximum connections to 200 but when looking at the connections used I can see that it's only 128 that are used.

Looking at the code for OpenAM 12 I see that its
set to a power of two in the getConnectionCount method.

public int getConnectionCount(int max, ConnectionType type) {
    Reject.ifTrue(max < MINIMUM_CONNECTIONS);
    switch (type) {
        case CTS_ASYNC:
            if (storeMode == StoreMode.DEFAULT) {
                max = max / 2;
            } else {
                max = max - 2;
            }
            return findPowerOfTwo(max);
        case CTS_REAPER:
            return 1;
        case DATA_LAYER:

But I lack any information about why this is needed. The Installation guide does not mention this restriction as far as I can see either, so I wonder what might be the reason behind this.

I hope that someone out there can explain this so it makes sense, but I feel like this might be a leftover from previous versions and can/should be removed.

Kind regards,
Vincent


_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam
Reply | Threaded
Open this post in threaded view
|

Re: CTS Connectionpool

Major Péter
Hi,

it was implemented this way to ensure equal distribution amongst the asynchronous queues. You see, each connection to the CTS is associated with a queue of tasks that will be asynchronously carried out by OpenAM. In order to ensure that operations related to a particular token always ends up in the same queue (and hence LDAP connection), we are using the token ID's hashcode value (mod number of connections) to determine which queue to use. There is a lovely post here that shows that [1] is no modulus bias at all when using power of 2, hence this should mean that tasks are distributed evenly amongst the queues (and connections).


cheers,
Peter

2016-11-11 16:19 GMT+00:00 Vincent Koldenhof <[hidden email]>:
Hi all,

Is there a reason why the number of connection in the connectionpool to the CTS needs to be a valid power of 2?
During testing I have set the maximum connections to 200 but when looking at the connections used I can see that it's only 128 that are used.

Looking at the code for OpenAM 12 I see that its
set to a power of two in the getConnectionCount method.

public int getConnectionCount(int max, ConnectionType type) {
    Reject.ifTrue(max < MINIMUM_CONNECTIONS);
    switch (type) {
        case CTS_ASYNC:
            if (storeMode == StoreMode.DEFAULT) {
                max = max / 2;
            } else {
                max = max - 2;
            }
            return findPowerOfTwo(max);
        case CTS_REAPER:
            return 1;
        case DATA_LAYER:

But I lack any information about why this is needed. The Installation guide does not mention this restriction as far as I can see either, so I wonder what might be the reason behind this.

I hope that someone out there can explain this so it makes sense, but I feel like this might be a leftover from previous versions and can/should be removed.

Kind regards,
Vincent


_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam



_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam
Reply | Threaded
Open this post in threaded view
|

Re: CTS Connectionpool

Vincent Koldenhof-2

Hi Peter,

Thank you for the clarification and the link to the blogpost, it's very much appreciated.

Kind regards,

Vincent


Op 11/11/2016 om 17:41 schreef Major Péter:
Hi,

it was implemented this way to ensure equal distribution amongst the asynchronous queues. You see, each connection to the CTS is associated with a queue of tasks that will be asynchronously carried out by OpenAM. In order to ensure that operations related to a particular token always ends up in the same queue (and hence LDAP connection), we are using the token ID's hashcode value (mod number of connections) to determine which queue to use. There is a lovely post here that shows that [1] is no modulus bias at all when using power of 2, hence this should mean that tasks are distributed evenly amongst the queues (and connections).


cheers,
Peter

2016-11-11 16:19 GMT+00:00 Vincent Koldenhof <[hidden email]>:
Hi all,

Is there a reason why the number of connection in the connectionpool to the CTS needs to be a valid power of 2?
During testing I have set the maximum connections to 200 but when looking at the connections used I can see that it's only 128 that are used.

Looking at the code for OpenAM 12 I see that its
set to a power of two in the getConnectionCount method.

public int getConnectionCount(int max, ConnectionType type) {
    Reject.ifTrue(max < MINIMUM_CONNECTIONS);
    switch (type) {
        case CTS_ASYNC:
            if (storeMode == StoreMode.DEFAULT) {
                max = max / 2;
            } else {
                max = max - 2;
            }
            return findPowerOfTwo(max);
        case CTS_REAPER:
            return 1;
        case DATA_LAYER:

But I lack any information about why this is needed. The Installation guide does not mention this restriction as far as I can see either, so I wonder what might be the reason behind this.

I hope that someone out there can explain this so it makes sense, but I feel like this might be a leftover from previous versions and can/should be removed.

Kind regards,
Vincent


_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam




_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam


_______________________________________________
Visit the OpenAM forum at https://forgerock.org/forum/fr-projects/openam/
OpenAM mailing list
[hidden email]
https://lists.forgerock.org/mailman/listinfo/openam