Archived

This forum has been archived. Please start a new discussion on GitHub.

multiple threads, single connection problem

i have read the documentation and verified the codes that though we have multiple threads, we only have estabished one single connection to the server, that eventually multiple threads will block on this synchroize block in the following method:

<code>
ConnectionI.sendRequest
</code>

i want to seek for verification of my understanding and any suggestion if appropriate

this is our current setup:

mutiple ice servers are setup with different IPs, but clients will connect to these servers by another single IP, and that IP will forward to either one of the actual ice server ip by our load balancer
(this was a historical setup...)

now, the situation is
once our client is connected to one of the ice server, it never change to other servers (this is expected after i read the documentation and verify that by code)

but we also find that only one single connection is created, even we have multiple client threads are created to serve the requests

the question is
- even we have multiple threads, eventually all those threads will be serialized to wait for the single connection ?
- if it is so, is there any mean to have multiple connections per single proxy? (without using the IceGrid for clustering/failure over/load balancing)

Comments

  • mes
    mes California
    Welcome to the forum!

    You can force a proxy to use a different connection by assigning it a unique "connection id" (see this this section of the manual). You can use this however you like; for example, you can give each proxy a different id, in which case each proxy creates its own connection. Another option is to create a pool of ids if you are concerned about creating too many connections.

    Here's a code sample:
    // Java
    Ice.ObjectPrx proxy = ...
    Ice.ObjectPrx proxy1 = proxy.ice_connectionId("id1");
    
    Cheers,
    Mark
  • mes
    mes California
    I forgot to respond to this question:
    ywtsang wrote: »
    even we have multiple threads, eventually all those threads will be serialized to wait for the single connection ?
    Multiple threads can share a single proxy and a single connection. If Thread A is blocked waiting for the response to a twoway invocation, Thread B can still make invocations on the same proxy without being blocked by the activities of Thread A.

    Let us know if you need more information.

    Mark
  • something doubtful is found

    we find that the server has warning message on the thread pool:

    Size=10, SizeMax=10, SizeWarn=10
    warning: thread pool `Ice.ThreadPool.Server' is running low on threads


    and try to read the thread dump, and it also shows that multiple threads are running to serve the request

    so that means we still can serve for multiple requests even we have one single connection?
  • mes wrote: »
    Welcome to the forum!

    You can force a proxy to use a different connection by assigning it a unique "connection id" (see this this section of the manual). You can use this however you like; for example, you can give each proxy a different id, in which case each proxy creates its own connection. Another option is to create a pool of ids if you are concerned about creating too many connections.

    Here's a code sample:
    // Java
    Ice.ObjectPrx proxy = ...
    Ice.ObjectPrx proxy1 = proxy.ice_connectionId("id1");
    
    Cheers,
    Mark

    thanks for the quick response,

    does that mean we need to create multiple proxies? i.e. we need to pick up one from the list of created proxies when needed?
  • mes
    mes California
    ywtsang wrote: »
    so that means we still can serve for multiple requests even we have one single connection?
    Yes, that's correct. An object adapter can service up to N simultaneous invocations, where N is the maximum size of the thread pool.

    Cheers,
    Mark
  • mes
    mes California
    ywtsang wrote: »
    does that mean we need to create multiple proxies? i.e. we need to pick up one from the list of created proxies when needed?
    You don't necessarily need to use the same proxy object. If you create a proxy with the connection id of an existing connection, that proxy will share the connection with other proxies having the same id.

    Cheers,
    Mark