Why didn’t I use DynamoDB for my API/Service

Amit Mishra
Aug 25, 2017 · 3 min read

Recently I was assigned a task to write a Go service using DynamoDB. So I started evaluating it. As you already know that Dynamo DB is a No SQL service provided by AWS. There were few obvious reasons for us to use dynamoDB:-

  1. It is very very cheap. No one can beat it.
  2. It is fully managed, we don’t have to worry about anything. Replication is fully managed so loss of data is almost none. It has seamless scaling, So it doesn’t require manual Sharding.
  3. It is very reliable. Chances to failure(read/write) very very low.
  4. It is fast( it uses SSD internally).
  5. Its easy to integrate with other AWS services.

There are endless reasons to use it , I can keep listing out here. So before we started writing code, I was asked to play around it and see if our use cases align to out-of-box features provided by dynamoDB.

Few of our use-case were:-

  1. Service should support key based filtering.
  2. Service should return total count for all the items.
  3. Service should be able to limit the results based on some params.
  4. Service should be able to sort results based on any key.
  5. Service should be able to support startIndex and endIndex based filtering for items.
  6. Service should be able to support pagination.

You can see, these are pretty much basic use-cases, which everyone wants to have as part of their service features. Now lets go through each use-case one by one from DynamoDB point of view.

  1. Service should support key based filtering :- By-default you can use primary key or partition key to filter items in DynamoDB. If you want to support filtering based on other keys, then you can create GSI(Global Secondary Index) for the key and you are good to go to use this key as queryInput to filter data.
  2. Service should return total count for all the items:- In order to use it you can use DynamoDB scan operation and get count for all the items contained in table.
  3. Service should be able to limit the results based on some params:-Dynamo DB query operation supports it. You can add “Limit” attribute to queryInput in order to restrict the number of results.
  4. Service should be able to sort results based on any key:- DynamoDB doesn’t have any support for individual key based sorting. When you create a table in DynamoDB, it lets you add a sort key with partition key, which basically returns sorted result based on the composite key(partition key+ sort key). If you wan to sort result based on any key then you can not do it.
  5. Service should be able to support startIndex and endIndex based filtering for items:- This is another use case which dynamoDB doesn’t support out of box. There is no support for numbered params to filter results from DynamoDB.
  6. Service should be able to support pagination:- By Default DynamoDB return 1 MB of resultset. If it still has more data as part of resultset then it will include LastEvaluatedKey as part of response, which you can use as ExclusiveStartKey for next iteration. Very easy to use but as a user I don’t want to keep track of LastEvaluatedKey. It seems to be unnecessarily complicated.

As per above analysis, we can clearly see that we are not able to get out-of-box support for last three critical use cases.

Also about 2nd use case, we had to use scan operation, which is very slow operation as par AWS. In fact we have noticed, around 20 minutes of delay for one of our service, where we needed to scan around 2 millions of items.

So overall we couldn’t get out-of-box support for 3 or 4 use-cases out of 6 which was very disappointing and one of the main reason, we had to stop thinking about using DynamoDB at-least for this service. Few people say, DynamoDB is cheap, just because it doesn’t have to support for the use-cases which I mentioned. but off-course you just do not want to spend money on something which is cheap but useless for you.

DynamoDB might be good, fast ,cheap and still fully managed service provided by AWS. But it clearly did not fit to our requirements. Hopefully it is right fit for you but before you decide and reach to any conclusion , please list down all your critical use case and check if you got the support for these as DynamoDB, is not a good fit for lots of things!!!!!

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade