0

The scenario

A large, high performance, scalable, distributed site about cats.

The details

  • Each cat has it's own page containing some details such as average sleep hours, favourite food and worst enemies.
  • Pages can be accessed either via a vanity-url when set (ie. cats.com/terminator-cat) or a Base64Url representation of it's UUID (ie. cats.com/w4rTb789mmN0c...)
  • There is an API aswell, which accepts only the Base64 form.
  • The UUID is hidden from public for url friendliness purposes.
  • The site uses Cassandra 2 as it's main db.
  • Extra details to consider, there will also be other queries in the form of: find cats with X favourite food, Y enemies, ... this is however not what is being asked.

Questions

Knowing the data to be stored and how it will be queried, what would be the correct way to model it?

I had in mind a cat table, where each entry key is the UUID. And two separate lookup tables, one for the Base64 encoded strings and the other for the custom names.

The page controller would look if the url parameter is a Base64 String, if so first query the loookup table to get the UUID and then query the data table. If it's not, query the name lookup table and then the data. If not found in the lookup or data tables return 404.

Is there any problem with this approach? What should I consider? What other ways would you recommend?

I must say I'm new to Cassandra, any tips will help.

xplaza
  • 1

1 Answers1

0

If it is not too late into your development, I recommend just using sha-256 of the vanity URL as your id and do one lookup. With this approach, you have to make your interface such that it does not allow changing of vanity urls, after they are set, and you should make that a required field. This simplified your app alot.

Arya
  • 2,135
  • 15
  • 13
  • Not too late, just starting. That would indeed simplify a lot, but for this project I really want the vanity url to be optional. The "cats" is going to be user generated content and I don't want to force having to set it at creation time, also not all users will have permission to create them. – xplaza Jan 27 '14 at 22:39
  • You can decode base64 strings, so you won't need a lookup table for that. With that in mind, keep your cat table as is and just have the vanity -> uuid lookup table. For base64encoded strings, just call the string with base64decode and the result should be the uuid referring to a cat. – Arya Jan 28 '14 at 23:34
  • Ouch.. that's it! thank you! I was thinking on hashing and missed base64 can be decoded. Could feel something was wrong. You can repost it as an answer and I will accept it. Apart from that, probably there is not much more that can be done, maybe some specific Cassandra tunning for the lookup table, will look into it. – xplaza Jan 29 '14 at 01:48