Tuesday, August 6, 2013

7 Reasons You Should Use MongoDB over DynamoDB

Even recently I migrated from MongoDB to DynamoDB, and shared 3 reason to use DynamoDB. I still love MongoDB, really good NoSQL solution. Here are some points for you to make decision on using MongoDB over DynamoDB.

Reason 1: Use MongoDB if your indexing fields might be altered later.
With DynamoDB, it's NOT possible to alter indexing after being created. I have to admit that there are workarounds. For example, you can create a new table and import data from the old one. But no one is straightforward and you need some trade off if using workaround. Back to indexing, DynamoDB allows you define a hash key to make the data well-distributed, and then adding range key and secondary index. When query from table, hash key must be used, and then either range key or one of secondary indices. No complex query supported. The hash key, range key and secondary index key definition can NOT be changed in future. So your database structure must be well designed before going production. By the way, the secondary key will occupy additional storage. If you have 1G data, and if you create index and "project" all attribute to the index, then your actually cost of storage will be 2G data. If you project only the hash and range key value to index, then you need to query twice to get the whole record. Actually the API allows you to invoke query only once, but the cost to "read" capacity is twice. In addition, you can still "scan" the data and filter by conditions on un-indexed key, but please check the data in my previous post, scan could be 100 times (or more) slow than query.

Reason 2: Use MongoDB if your need features of document database as your NoSQL solution.
If you will save document like this:
  _id: 1,
  name: { first: 'John', last: 'Backus' },
  birth: new Date('Dec 03, 1924'),
  death: new Date('Mar 17, 2007'),
  contribs: [ 'Fortran', 'ALGOL', 'Backus-Naur Form', 'FP' ],
  awards: [{
      award: 'National Medal of Science',
      year: 1975,
      by: 'National Science Foundation'
  }, {
      award: 'Turing Award',
      year: 1977,
      by: 'ACM'
(sample document from MongoDB technical document)
With document database, you'll be able to query by name.first, or if some value exists in sub-document of awards. However, DynamoDB is key-value database, and support only value or set, no sub-document supported, and no complex index and query supported. It's not possible to save sub-document { first: 'John', last: 'Backus' } to name, accordingly, not possible to query by name.first.

Reason 3: Use MongoDB if you are going to use Perl, Erlang, or C++.
Official AWS SDK support Java, JavaScript, Ruby, PHP, Python, and .NET, while MongoDB supports more. I used node.js to build my backend server, both AWS SDK for node.js and mongoose SDK for MongoDB works very well. It's really amazing to use mongoose for MongoDB. It's in active development and the defect I report to mongoose can be fixed soon. I have also experience of using AWS SDK for Java and morphia for MongoDB, both of them works perfect! SDK for AWS and MongoDB are all well designed and widely used. But if your programing language is not listed in official support list, you may need to evaluate the quality of the SDK carefully. I have ever used non-official Java SDK for AWS SimpleDB, it's also good. But I can still easily get defect, for example, when using Boolean in object persistence modal, the Java SDK for SimpleDB cannot handle this type and will introduce some bad result.

Reason 4: Use MongoDB if you may exceed the limits of DynamoDB.
Please be careful about the limits and read them carefully if you are evaluating DynamoDB. You may easy to exceed some of the limits. For example, the value you stored in an item(value of a key) cannot exceed 64k bytes. It's easy to exceed 64k bytes when you allow user to input content. User may input a 100k bytes text as article title just because of pasting it by mistake. There is also workaround. I divide the content to multiple keys if it exceed the limits, and aggregate to one key in the post processing stage after reading the data from DynamoDB server. For example, the content of an article database may exceed 64k bytes, then in the pre-processing stage when storing to DynamoDB, I divide it to article.content0, article.content1, article.content2 and so on. After reading from DynamoDB, I will check if keys article.content0 exists, and if article.content0 exists, then continue to check article.content1, and combine the value in these fields to article.content and remove the article.content0, article.content1, and so on. This will introduce the complexity of your code and introduce additional dependency to your code. MongoDB does not have these limitations.

Reason 5: Use MongoDB if you are going to have data type other than string, number, and base 64 encoded binary.
In addition to string, number, binary, and array, MongoDB supports date, boolean, and a MongoDB specified type "Object ID". I use mongoose.js, and it supports these data type well. When you define data structure for object mapping, you can specify the correct type. Date and Boolean are quite important types. With DynamoDB you can use number as alternative, but still, need additional logic in your code to handle them. With MongoDB you can get all these data types by nature.

Reason 6: Use MongoDB if you are going to query by regular expression.
RegEx query might be an edge case, but in case this happens in your situation. DynamoDB provided a way to query by checking if a string or binary start with some substring, and provided the "CONTAINS" and "NOT_CONTAINS" filter when you do "scan". But you know "scan" is quite slow. With MongoDB, you can query easily on any key or sub document with RegEx, for example, if you want to query by user's name for "John" or "john", you can query by a simple regular expression {"name" => qr/[Jj]ohn/}, while this cannot be completed in DynamoDB by 1 query.

Reason 7: Use MongoDB if you are a big funs of document database.
10gen is the company backing MongoDB. They are very active on community. I asked question on stackoverflow, and Dylan, a Solution Architect of MongoDB, actively follows up my question, helped me analyze the issue, looked for the cause, also gave some very good suggestions on MongoDB. This is really a very good experience. In addition, the MongoDB community are willing to listen to users. Amazon is big company, it's not easy to getting touch with the people inside, not to mention impacting their decision and roadmap.

Bonus Tips: Read carefully on DynamoDB document if you are going to use it.
For example, there is an API "batchWriteItem". This API may return no error but give a field with key "UnprocessedItems" in result. This is somewhat anti-pattern. When I invoke a call, the result could be either success or failed. But this API gives a different status: "partial correct". You need to manually re-submit those "UnprocessedItems" again until there is no item in it. I didn't notice this because it's never happens during the testing. However, when there are big traffic, and the count of request to DynamoDB exceeded your quote for several seconds, this may happen.

Hold on, before you made the decision on using MongoDB, please read 3 Reasons You Should Use DynamoDB over MongoDB.


  1. i wrote a module for nodejs users that mitigates some of those reasons:

  2. Thanks for the info. I visited your site for comparison of DynamoDB and MongoDB, because I'm looking for a cost-efficient managed db service other than hosted MongoDB for my startup. Then I saw your other articles adapting new technologies and developing a new business with overcome of limited time (with child) and resource. It really challenges me a lot :)

  3. Sorry, at the end, about your point 7, did that guy (Solution Architect of MongoDB) solve the cyclic slow response of your DB or the problem still persist?

    Thanks in advance

  4. Nice post.

    For the second reason, now the DynamoDB supports JSON, which is a big progress.


  5. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.

    SEO Training in Chennai

  6. Your thinking toward the respective issue is awesome also the idea behind the blog is very interesting which would bring a new evolution in respective field. Thanks for sharing.

    SEO Company in Chennai

  7. nice! thank you so much! Thank you for sharing. Your blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including merecruitment agency

  8. Many rumors are going on regarding the differences between the MongoDB and the DynamoDB among the consumers.The features those are available in the both version should be varified for the benefits of the users.This college paper writing service reviews will let the consumers know about the various migrating related methods of the both MongoDB and DynamoDB.

  9. Nice sharing. MongoDB is a widely used open source database system. Scop for mongodb is increasing day by day. Learn MongoDB Training from expert reach gangboard. Selenium Training

  10. The parousia of Drink can be followed to archaean 90's yet now it is likewise sorted out in motile applications and amusement making versatility a train realness. Java

  11. Very Nice Blog I like the way you explained these things. I’ve been looking for ways to improve my website and overall rankings.I hope your future article will help me further.Take SEO Training in Chennai to mould yourself.


  12. Nice it seems to be good post... It will get readers engagement on the article since readres engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

  13. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.

    selenium training in chennai|
    selenium training in bangalore|

  14. Thanks a lot for sharing this with all of us, I like it and we can communicate. Do you need buy app ratings and reviews. To boost app ranking and double app downloads now.

  15. Thank you For generating valuable information For Us....Very Nice Blog....
    Thanks@Selenium Online Training


  16. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
    Php course in chennai

  17. Nice post By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
    Digital Marketing Training

  18. Hey, Your post is very informative and helpful for us.
    In fact i am looking this type of article from some days.
    Thanks a lot to share this informative article....best regards.
    websphere training in hyderabad

  19. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
    RPA courses in Chennai
    RPA Training Institute in Chennai
    German Classes in Chennai
    German Language Classes in Chennai
    German Language Course in Chennai
    German Courses in Chennai

  20. Excellent post!!! These provide very nice ideas and different kinds of wrathful details. Thank you for your sharing with all. I am waiting for your more ideas...
    Ethical Hacking Course in Chennai
    Hacking Course in Chennai
    Certified Ethical Hacking Course in Chennai
    Ethical Hacking Training in Chennai

  21. In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips. I like your writing style and I hope you will keep doing this good working.
    PHP Training in Chennai
    DOT NET Training in Chennai
    Big Data Training in Chennai
    Hadoop Training in Chennai
    Android Training in Chennai
    Selenium Training in Chennai
    Digital Marketing Course in Chennai
    JAVA Training in Chennai
    Selenium training institute in Chennai

  22. This comment has been removed by the author.


  23. You are doing a great job. I would like to appreciate your work for good accuracy
    Selenium Training Institute in Chennai | Selenium Testing Training in chennai

  24. I feel happy to say this I will deeply learn your blog and it’s really useful for me, keep sharing like this type valuable information regularly, I like to thanks for sharing this superb blog I hope I see you soon again time, thank you so much.
    redmi service center in t nagar
    redmi service center in velachery
    redmi note service center in chennai
    redmi mobile service centre in chennai

  25. It might seem clear to fuse a logo you begin marking your business venture however it might stun you that a great deal of organizations regularly neglect to give any thought to their logo structure or even to incorporate one by any means. logo design service

  26. Dengan mengandalkan beberapa jawaban diatas, maka kemudian anda bisa simpulkan sendiri apakah memang main dengan mantra main judi kiu kiu itu bagus atau tidak untuk dilakukan. Selamat mencoba..
    bandar ceme
    freebet tanpa deposit
    paito warna terlengkap
    syair sgp

  27. Mereka berbasis situs sehingga kalau kita mau bergabung, kita juga harus melakukan semua prosesnya dengan online juga. Kalau anda memang mau mendapatkan keuntungan yang besar
    bandar ceme
    paito warna
    forum prediksi

  28. Thanks For sharing an informative blog keep rocking bring more details
    Best web design company in chennai

  29. thanks for your information really good and very nice web design company in velachery

  30. This is a great article, I have been always to read something with specific tips! I will have to work on the time for scheduling my learning.
    web design company in velachery

  31. DevOps Training in Chennai
    I am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.

  32. DevOps Training in Chennai

    I am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.

  33. we are providing best java training in coimbatore..please visit the link

  34. GrueBleen – One of the best branding and marketing agency in Riyadh- Saudi Arabia. If you need the details, click the below link
    Branding Agency Riyadh
    Marketing Agency Riyadh

  35. Agriculture Solutions – Taldeen is a plastic manufacturing company in Saudi Arabia. They are manufacturing agricultural plastic products like greenhouse cover and hay cover. Visit the below link to know more details
    Agriculture Solutions
    Greenhouse Cover

  36. BSc in Optometry – Here is the details about Best BSc Optometry Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best OPT colleges in Bangalore. If you are looking to study BSc Optometry in Bangalore, click the below link.
    Optometry Colleges In Bangalore

  37. BSc Cardiac Care Technology – Here is the details about Best BSc Cardiac Care Technology Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best BCC colleges in Bangalore
    BSc Cardiac Care Technology Colleges In Bangalore

  38. GrueBleen – One of the best social media marketing agency in Riyadh- Saudi Arabia. Visit here for the all service details of GrueBleen.
    Social Media Marketing Agency

  39. Jadi, PayPal ini merupakan salah satu sistem ataupun mekanisme pembayaran yang nantinya bisa dilakukan dengan secara on the web. Nah, kunjungi pulsa dengan paypal pada intinya PayPal tersebut adalah sebuah perusahaan yang memang menawarkan jasa transfer ataupun penerimaan uang melalui surat elektronik.

  40. Great efforts put to publish these kinds of articles that are very useful to know. I’m thoroughly enjoying your blog. And Good comments create great relations. You’re doing an excellent job. Keep it up.

    Magento Development Training Course in Chennai Zuan Education

    Selenium Training Course in Chennai Zuan Education

  41. Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
    Digital Marketing Course In Kolkata

  42. Stadion Olimpico adalah rumah bagi kedua Roma dan Lazio dan dibangun untuk 1960 Olimpiade. Mengesankan 82.000 ditambah tempat itu telah menampung Final Piala Eropa dan Final Piala Dunia 1990. Itu juga merupakan rumah pilihan pertama tim nasional Italia 98toto

  43. C C++ Training in Chennai

    I am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.


  44. Astonishing article that I have never seen before. I aimed to write an article based on this tally field, but my startings were rejected...Now, the information that you have designed in this blog was misery to read about this tally and its technical features. Surely these writings will help the beginners and the professionals. Thanks

    Tally ERP 9 Training
    tally classes
    Tally Training institute in Chennai
    Tally course in Chennai
    seo training classes
    seo training course
    seo training institute in chennai
    seo training institutes
    seo courses in chennai
    seo institutes in chennai
    seo classes in chennai
    seo training center in chennai

  45. I really appreciate your method to explaining, I hope to see more posts from your blog. thank you!
    Digital Marketing Course In Kolkata
    Web Design Course In Kolkata
    SEO Course In Kolkata

  46. Nice article. I liked very much. All the informations given by you are really helpful for my research. keep on posting your views.
    ccna course in Chennai
    ccna Training in Chennai
    ccna Training institute in Chennai
    ccna institute in Chennai
    Best CCNA Training Institute in Chennai

  47. With the help of creative designing team TSS advertising company provides different branding and marketing strategies in advertising industry...

  48. Such a wonderful article and I feel that it is best to write more on this topic. Thank you so much because i learn a lot of ideas about it. Keep posting...
    Digital Marketing Course In Kolkata
    Web Design Course In Kolkata
    SEO Course In Kolkata

  49. i have been following this website blog for the past month. i really found this website was helped me a lot and every thing which was shared here was so informative and useful. again once i appreciate their effort they are making and keep going on.

    Digital Marketing Consultant

  50. Thank you so much for sharing this useful iformation
    We are Professional C and C++ Training Institute in Coimbatore by Qtree Technologies. Our Students are get training form real time project experience & 100% job placement .Rated as Best C and C++ Training Certification Courses in Coimbatore. Call Now!
    C and C++ training in coimbatore
    big data training in coimbatore
    hadoop training in coimbatore
    amazon web services training in coimbatore
    aws training in coimbatore
    ios training in coimbatore

  51. I am quite new user here but I found it very interesting for my work because I am a writer and I have to refrain from these 7 reasons that will make my work haphazard.
    Assignment writing services

  52. I visited your site for comparison of DynamoDB and MongoDB, because I'm seeking out a value-efficient managed db service aside from hosted hrm dissertation topics in UK MongoDB for my startup. Then I noticed your other articles adapting new technology and growing a brand new commercial enterprise with conquer of limited time with child and resource. It really challenges me a lot.

  53. I have been following this internet site blog for the beyond month. I clearly found this website was helped me plenty and every element which assignment writing services changed into shared right here turned into so informative and beneficial. Again once i respect their attempt they may be making and maintain occurring.

  54. Thanks for sharing this nice informations.
    CCNA Course in Coimbatore

    CCNA Training Institute in Coimbatore

    Java training in coimbatore

    Software Testing Course in Coimbatore

    python training institute in coimbatore

    data science course in coimbatore

    android training institutes in coimbatore

  55. I absolutely love your site.. Very nice colors & theme. Did you develop this amazing site yourself? Please reply back as I’m wanting to create my own personal technology website and would love to know where you got this from or what the theme is named. Thanks!

  56. This great article has really peaked my interest. I am going to book mark your blog and keep checking for new information about once per week.
    Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery

  57. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    Business Analytics Training
    Business Analytics Course In Hyderabad

  58. Thank you for such a wonderful blog. It's a very great concept and I learn more details from your blog. Try
    Snaplogic Training
    Snowflake Training
    Talend Big Data Training
    Oracle Fusion Cloud Training

  59. Thanks a lot for sharing such a good source with all, i appreciate your efforts taken for the same. I found this worth sharing and must share this with all.

    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery

  60. What a great post that you have shared here about your dynamodb. You make information effortless for us that we get good facts about it. Thanks for this informative blog. Oracle Fusion Scm Online Training

  61. I need an advanced printing machine for my printing services. Printer plays an important role in completing printing tasks. So, I need a printing machine for the excellent printing services. I believe in using HP products because of unique and exciting features and advanced printing functions. So I want to set up HP printer with the help of 123.hp.com/setup. I have opened this website in the favorite browser and click on download option. After this step, I am facing problems for the set up procedure. I am not able to guess what I should do for this set up procedure. So anyone can suggest the easy tips to set up HP printer using 123.hp.com/setup.