Shutterfly Interview Question
Software Engineer / DevelopersCountry: United States
Sharding is an appropriate solution for a situation like this where there's a fixed number of machines.
nodeNumber = hash % numberOfNodes;
Even load balancing is more important if you have physical machines because each machine will have a separate hard disk. So then you might want to invest in additional features like either using a secure hash function to ensure that it's very likely the distribution is even, or implementing some sort of re-balancing mechanism.
Unfortunately, could not code or optimize this properly. My solution involved a very simple sharding of the hash table by modding the kv hash by the node-id. I believe the interviewer was not very satisfied with the approach.
- edoc0code August 08, 2012