educative.io

Updating trie offline in auto ahead suggestion system - How?

Question:

As a part of auto-ahead/ autosuggestion system:

One of the strategies of updating trie is:

We can make a copy of the trie on each server to update it offline. Once done we can switch to start using it and discard the old one.

How do we do this, update offline and discard other? Elaborate?


Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers

Hi @Pradyumna, thanks for reaching out.

We can have a Map-Reduce (MR) set-up to process all the logging data periodically say every hour. These MR jobs will calculate the frequencies of all searched terms in the past hour. We can then update our trie with this new data. We can take the current snapshot of the trie and update it with all the new terms and their frequencies. We should do this offline as we don’t want our read queries to be blocked by update trie requests. We can have two options:

  1. We can make a copy of the trie on each server to update it offline. Once done we can switch to start using it and discard the old one.
  2. Another option is to have a primary-secondary configuration for each trie server. We can update the secondary while the primary is serving traffic. Once the update is complete, we can make the secondary our new primary. We can later update our old primary, which can then start serving traffic, too.
1 Like