educative.io

How can replicas replaces sharding?

In the chapter,it is mentioned that : “Having replicas of QuadTree servers can provide an alternate to data partitioning.”
And few lines back it is mentioned : “With 20% growth each year we will reach the memory limit of the server in the future. Also, what if one
server cannot serve the desired read traffic? To resolve these issues, we must partition our QuadTree!”

But my point is, replicas are needed only in case we dont do sharding. Replicas cannot replace sharding.If it is the case, means one server has enough memory to hold the data.Both above points contradict each other.Please clarify

I also have the same question. @Design_Gurus

As mentioned in the chapter, partitioning can be done for two reasons:

  1. If the data can’t be stored on one machine, or
  2. Although we can fit our data on one machine, the read traffic is too much that one server can’t handle the scale, and also it is a single point of failure.

“Replica replacing the partitioning” refers to point 2. Our data can easily fit on one machine, but to handle read traffic we can replicate the data on multiple servers.

Now with future growth, we can end up with the scenario mentioned in point 1 - “The data is large enough to not fit on one server”.

During the interview, it is always a good idea to evolve the solution. As in this case, the scale requirements do not need a partitioned solution, but for future needs, we should discuss this. Hence, it is suggested to partition the data and replicate it too.

1 Like

This finally makes sense now. I though partition by location id makes 0 sense because after partitioning, you know need to literally go to all the servers to get a complete list of locations nearby. So instead of hitting one server which is hot, you are hitting all servers with all requests. I had no idea why that partitioning is beneficial.

But if partition by location is just because

Then that makes sense. We are splitting the quad tree to two machines just because one machine cannot hold the entire tree.

Celebrity issues are resolved by replication, not partitioning here.