I have a cluster of micro services with an exposed search API serving a client app. I want to "stream" in real time the aggregated results of a complex search. The search will be kicked of by the client calling the search API which in turn adds a message to a queue. This will be picked up by an orchestrator service which will in turn make calls to 1 or many partner APIs.

My search API has a signalR hub which streams the results of the search in a way akin to this example. My question is what are some messaging strategies for delivering new elements from the orchestrator to the search API hub stream.

I have thought of two possibilities (there are undoubtedly many more)

  1. The orchestrator loads elements into a cache which is in turn polled by the Search API, and new elements added to the stream.

enter image description here

  1. The orchestrator adds elements to a response message queue, the Search API listens and adds new elemnents to the stream.

enter image description here

Which idea sounds more reasonably?

My idea was to have correlating ID for the search and response elements, making the cache implementation a bit simpler and potentially a bit easier to scale horizontally.

For the response queue, I'm not sure how you'd go about listening only for the items you want for this request / thread. Probably more of an implementation detail, I'm not sure.

  • What is your definition of "reasonable?" The only difference between your two diagrams appears to be the part where you use a search response queue instead of a cache. Have you given some thought to what the difference is and how it affects your project specifically? – Robert Harvey Mar 23 '19 at 14:37
  • I’m just looking at the usual performance and scalability trade offs. To be honest I just don’t know enough about messaging and need some direction. Originally I thought if I was streaming to the browser, why not take a similar approach between two servers using a socket connection.. and is there such a thing as a temporary queue that I can spin up for each specific request? Sorry a lot of questions, perhaps I need to rewrite this post – cookee89 Mar 23 '19 at 23:10
  • 1
    Some general advice: don't solve a performance problem you don't have. Only solve performance problems that are identified by measurements. – Robert Harvey Mar 23 '19 at 23:51
  • Thank you. Great advice – cookee89 Mar 24 '19 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.