Archived

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

Connection Reuse Management

First a bit of history. I have an ice client that is sending data via multiple threads to a set of ice servers through a hardware load balancer. The key point is "through a hardware load balancer." Thus the stringified proxy is exactly the same for each thread and the proxies are created in the same manner. From what I can tell this qualifies the proxies to reuse the same connection. However I would like the balancer to be able to do its job. Thus if each thread had its own connection, the load balancer could distribute them to different hosts. Also I would like it if these connections were closed every now and again such that when a new connection is opened the load balancer could again do its magic.

So the problem has two parts. One, how do I get a different connection for each thread? And two, how do I actively close/restart these connections over time?

It would be nice if there were a configuration property that said use a different connection per client thread thus dealing with problem part one, but I couldn't find one. Does such a property exist? Also it would be nice it Active Connection Management could be told to gracefully close connections after a certain time even if they are not idle thus dealing with problem part 2, but I couldn't not find such a configuration. Does one exist?

Assuming the above are not options, I realize I can use connection ids. To solve problem part one I can base the connection id on the thread id, thus each thread will be guaranteed its own set of connections. To solve problem part two I can base the connection id on an interval in time, thus as I create proxies over time each proxy created in a new time interval will create a new connection.

So let me restate this to make sure I am being clear. Each thread has a loop. In the loop a proxy is created with the connection id being "<THREAD_ID><MINUTE_X>". Thus for every thread and for every minute a new connection id is created. ACM will then follow behind and clean up connections for connection groups that are no longer used, i.e., a thread has ended or an new minute has begun. I assume this will work only if ACM or something also cleans up structures/memory that are used by the connection id group that no longer has any active connections. Is this the case?

If this is not the case then I need another solution. Since my threads last the duration of the program then I could still use a connection id of "<THREAD_ID>" and just explicitly close the connection every time interval. Is this a better solution anyway?

Do you have any other suggestions?

Thanks for your time in helping me to understand this.
Kalon

Comments

  • matthew
    matthew NL, Canada
    I think you have a good understanding of the problem. I think what I'd do in this case is assign a unique connection id to the proxy associated with each thread, and then have a timer that explicitly closes the connection at regular intervals. This is simpler because you then don't need the sending thread to re-sync the proxy it is using when the connection id changes.

    Since you would be explicitly closing the connections using the timer, there is no need for ACM to do anything.