Question

I need to store a condition variable that must be accessed and updated by multiple modules.

The system has a web front-end (servlet container) that accepts http calls and translates them to requests messages that are posted to a message queue.

The messages are consumed by multiple processing modules having the same functionality, each running in separate JVM instance.

The processing modules might need to call some external web service to retrieve fresh information. There are 4 alternatives web services and the decision which service to call needs to be based on the average response time of the web service during last 10 minutes.

My question is how to store the information about web service response time?

My idea was NOT to use a shared DB for that and try to store shared variable (in a dedicated topic on a queue?) that can be read by and updated by processing modules whenever they need to make a decision which web service to call. The update is really simple since we are talking average response time (the previous average, first and last update TS and the current response time should be enough).

The concurrency is not an issue because there are only 20-30 processing modules and average request rate is 1 every few seconds. Even if there are some collisions, we have some tolerance to outdated values.

Was it helpful?

Solution

I would have your response time messages sent to a topic and every node which needs this information take a copy. When a node need to know which service to use, it looks at its local copy. This way the lookup is very fast and the nodes can run independently.

BTW You may need to periodically check the latency of the slower systems. i.e. once a system appears slow it won't be used again and so you won't see that it is not slow any more. You could periodically check all the servers to see if their performance has changed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top