Reputation: 182
This service is a remote session pool
. I need to ask for a session to work with other services. In most cases, this pool will have a session available, so in 15ms i will have a response. But sometimes, it will need to create a session on demand, requiring up to 800ms to create it.
I have two options in mind to handle this situation:
To set a 15ms timeout, and to implement a retry policy up with an exponential back off until 800ms. This service will create the required session no matter whether I am connected to it.
To set a 800ms timeout, and to keep connected to the service until a session is available for me.
In both cases, there's no guarantee that I will have a session after 800ms.
So the question is: Which are the pro/cons for each option?
Upvotes: 4
Views: 562
Reputation: 2554
1 . To set a 15ms timeout, and to implement a retry policy up with an exponential back off until 800ms. This service will create the required session no matter whether I am connected to it.
Pro
Cons
2 . To set a 800ms timeout, and to keep connected to the service until a session is available for me.
Pro
Cons
-
I think the decision driver is if you need a solution that just works for this use case or if this approach will be used for different clients and use cases.
PS: If you need to create a solution for different clients maybe will be worth to create a more complex protocol, like:
// just takes a session if available, no more than 15msec delay expected
get_session(...) : session
// if not available, creates one
get_session_or_create(...) : session
available_sessions(...) : int
// between 0 and 1, the proportion of available sessions
availability(...) : double
...
It's up to the client how to use it.
And over dimension the timeout parameters by some safe %, depending on the session creation delay variance.
Upvotes: 1