educative.io

Which DB we use for KEY-DB for Tiny URL?

Which DB we use for KEY-DB?

Given for 6 character long string for keys, we would need
6 (characters per key) * 68.7B (unique keys) = 412 GB.

And for 7 character long, we would need 21 TB

I guess in either of the cases, a single master DB (like MYSQL) might not work.

… can we have a single DB with 412 GB space??

Plus we have to also support some sort of locking mechanism so that 2 or more KGS servers do not get the same keys for concurrency purposes.

I do not think MySql will work here with this scale.
What DB do you recommend here for Key DB? @Design_Gurus

It’s a very important fact that you left out. And 2 design questions depends on this.

ALSO, I think that KGS can be multiple. But can Key DB be sharded ?
I really do not think so? Because, how would you shard it?

Since these are unique random 6 characters keys, you cannot tell 1 key DB shard to generate string within a range because there is no range as such. So, that would mean there will be a monolithic single Key DB that would have a master and few slaves. Master will serve out traffic (will have used/unused tables).

Please reply ASAP!
Thanks

3 Likes

Hi @Manish_Pandey1,

Really a great question. Have you found any answer for this?

+1 I have the same question and theory/qa thread isn’t very helpful in this regard.