Design Search Service at Scale (Scatter Gather Pattern)

Part 2: A high-level overview of designing a search service using the Scatter Gather Pattern.Scatter Gather PatternIt is an asynchronous way of distributing (scattering) a task among loosely coupled components or systems and aggregating (gathering) the…


This content originally appeared on Bits and Pieces - Medium and was authored by Kamini Kamal

Part 2: A high-level overview of designing a search service using the Scatter Gather Pattern.

Scatter Gather Pattern

It is an asynchronous way of distributing (scattering) a task among loosely coupled components or systems and aggregating (gathering) the response within a predefined time window.

In this article, we will have a high-level overview of designing a search service using the Scatter Gather Pattern.

Search Service using Scatter Gather pattern

In the above diagram, the Search Dispatcher distributes the search query among the workers belonging to the worker group (say for instance). Each worker maintains its own instance of database (not a shared one). The query dispatch happens through a message broker where the Search Dispatcher acts as a producer and the Workers act as consumers of the query, using a specific topic.

After the message has been processed by the workers, the response is pushed to the message broker to a separate topic as producers. The Search Dispatcher reads the message and aggregates them to form a unified response for the end user.

In the above design, there are a few use cases that we need to address…

  1. What if the aggregation is a time-consuming process and the user is aware of it?
  2. How to deal with failures in the Worker group?

To deal with the above scenarios, let us decouple the Search Dispatcher and Search Aggregator.

a. The Search Dispatcher will be responsible to delegate tasks to the Workers in the group while the Search Aggregator will be responsible for the aggregation of the response.

b. We will introduce the concept of a unique identifier to mark each request sent to the message broker for processing. The same identifier will be used by the Search Aggregator to process the response of each individual query as one single record and save it in a separate database.

c. The user can get the status of the task by querying using the unique identifier.

Decoupling the search and aggregation task

Let us assume that the Worker Group is a third-party service where our system needs to be resilient to failures. To tackle such scenarios, we need to introduce a time window to process the response beyond which our Search Aggregator will not wait to collect the response from the message broker. That way, any failures in the third-party worker group can be ignored while aggregating the available response.

💡Note: To ensure the resiliency of the Worker Group, we can use a distributed configuration management system like Bit to manage the different versions of the worker nodes and their dependencies. With Bit, we can easily track changes and dependencies of the worker group and ensure that each worker node is running the correct version of the code. Learn more about this here.
Morever, in case a new version causes unexpected failures in the worker group, we can use Bit to quickly roll back to a previous version. You can find out more about this here.

Learn more here:

Advanced Bit Dependency Management and Configs

Now, the question is how is the load getting balanced in this case?

It is important to understand that message brokers at times, also act as load balancers and auto-scales themselves if needed. In the above scenario, we can introduce multiple instances of message brokers to reduce any performance bottlenecks in distributed systems.

References

Summary

In this article, we learned about the Scatter Gather design pattern and also designed a scalable Search Service using message brokers as the load balancer for the same. We will continue exploring more in future articles.

In one of my articles, I have discussed Designing Search Service at Scale using master-worker architecture here: https://medium.com/@kamini.velvet/design-search-service-at-scale-17a2d63a2915

Thank you ❤️ for reading this article, feel free to Subscribe, clap👏🏻 and share it.

From monolithic to composable software with Bit

Bit’s open-source tool help 250,000+ devs to build apps with components.

Turn any UI, feature, or page into a reusable component — and share it across your applications. It’s easier to collaborate and build faster.

Learn more

Split apps into components to make app development easier, and enjoy the best experience for the workflows you want:

Micro-Frontends

Design System

Code-Sharing and reuse

Monorepo

Learn more


Design Search Service at Scale (Scatter Gather Pattern) was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Bits and Pieces - Medium and was authored by Kamini Kamal


Print Share Comment Cite Upload Translate Updates
APA

Kamini Kamal | Sciencx (2023-02-23T02:46:58+00:00) Design Search Service at Scale (Scatter Gather Pattern). Retrieved from https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/

MLA
" » Design Search Service at Scale (Scatter Gather Pattern)." Kamini Kamal | Sciencx - Thursday February 23, 2023, https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/
HARVARD
Kamini Kamal | Sciencx Thursday February 23, 2023 » Design Search Service at Scale (Scatter Gather Pattern)., viewed ,<https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/>
VANCOUVER
Kamini Kamal | Sciencx - » Design Search Service at Scale (Scatter Gather Pattern). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/
CHICAGO
" » Design Search Service at Scale (Scatter Gather Pattern)." Kamini Kamal | Sciencx - Accessed . https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/
IEEE
" » Design Search Service at Scale (Scatter Gather Pattern)." Kamini Kamal | Sciencx [Online]. Available: https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/. [Accessed: ]
rf:citation
» Design Search Service at Scale (Scatter Gather Pattern) | Kamini Kamal | Sciencx | https://www.scien.cx/2023/02/23/design-search-service-at-scale-scatter-gather-pattern/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.