RR 314 DynamoDB on Rails with Chandan Jhunjhunwal

Episode 320 · June 13th, 2017 · 46 mins 47 secs

About this Episode

RR 314 DynamoDB on Rails with Chandan Jhunjhunwal

Today's Ruby Rogues podcast features DynamoDB on Rails with Chandan Jhunjhunwal. DynamoDB is a NoSQL database that helps your team solve managing infrastructure issues like setup, costing and maintenance. Take some time to listen and know more about DynamoDB!

[00:02:18] – Introduction to Chandan Jhunjhunwal

Chanchan Jhunjhunwal is an owner of Faodail Technology, which is currently helping many startups for their web and mobile applications. They started from IBM, designing and building scalable mobile and web applications. He mainly worked on C++ and DB2 and later on, worked primarily on Ruby on Rails.

Questions for Chandan

[00:04:05] – Introduction to DynamoDB on Rails

I would say that majority of developers work in PostgreSQL, MySQL or other relational database. On the other hand, Ruby on Rails is picked up by many startup or founder for actually implementing their ideas and bringing them to scalable products. I would say that more than 80% of developers are mostly working on RDBMS databases. For the remaining 20%, their applications need to capture large amounts of data so they go with NoSQL.

In NoSQL, there are plenty of options like MongoDB, Cassandra, or DynamoDB. When using AWS, there’s no provided MongoDB. With Cassandra, it requires a lot of infrastructure setup and costing, and you’ll have to have a team which is kind of maintaining it on a day to day basis. So DynamoDB takes all those pain out of your team and you no longer have to focus on managing the infrastructure.

[00:07:35] – Is it a good idea to start with a regular SQL database and then, switch to NoSQL database or is it better to start with NoSQL database from day one?

It depends on a couple of factors. For many of the applications, they start with RDBMS because they just want to get some access, and probably switch to something like NoSQL. First, you have to watch the incoming data and their capacity. Second is familiarity because most of the developers are more familiar with RDBMS and SQL queries.

For example, you have a feed application, or a messaging application, where you know that there will be a lot of chat happening and you’d expect that you’re going to take a huge number of users. You can accommodate that in RDBMS but I would probably not recommend that.

[00:09:30] Can I use DynamoDB as a caching mechanism or cache store?

I would not say replacement, exactly. On those segments where I could see that there’s a lot of activity happening, I plugged in DynamoDB. The remaining part of the application was handled by RDBMS. In many applications, what I’ve seen is that they have used a combination of them.

[00:13:05] How do you decide if you actually want to use DynamoDB for all the data in your system?

The place where we say that this application is going to be picked from day one is where the number of data which will be coming will increase. It also depends on the development team that you have if they’re familiar with DynamoDB, or any other NoSQL databases.

[00:14:50] Is DynamoDB has document store or do you have of columns?

You can say key value pairs or document stores. The terminologies are just different and the way you design the database. In DynamoDB, you have something like hash key and range key.

[00:22:10] – Why don’t we store images in the database?

I would say that there are better places to store the, which is faster and cheaper. There are better storage like CDN or S3.

Another good reason is that if you want to fetch a proper size of image based on the user devices screen, resizing and all of the stuff inside the database could be cumbersome. You’ll repeat adding different columns where we’ll be storing those different sizes of images.

[00:24:40] – Is there a potentially good reason for NoSQL database as your default go-to data store?

If you have some data, which is complete unstructured, if you try to store back in RDBMS, it will be a pain. If we talk about the kind of media which gets generated in our day to day life, if you try to model them in a relational database, it will be pretty painful and eventually, there will be a time when you don’t know how to create correlations.

[00:28:30] – Horizontally scalable versus vertically scalable

In vertically scalable, when someone posts, we keep adding that at the same table. As we add data to the table, the database size increases (number of rows increases). But in horizontally scalable, we keep different boxes connected via Hadoop or Elastic MapReduce which will process the added data.

[00:30:20] – What does it take to hook up a DynamoDB instance to a Rails app?

We could integrate DynamoDB by using the SDK provided by AWS. I provided steps which I’ve outlined in the blog - how to create different kinds of tables, how to create those indexes, how to create the throughput, etc. We could configure AWS SDK, add the required credential, then we could create different kinds of tables.

[00:33:00] – In terms of scaling, what is the limit for something like PostgreSQL or MySQL, versus DynamoDB?

There’s no scalability limit in DynamoDB, or any other NoSQL solutions.


David Kimura            

  • CorgUI

Jason Swett     

  • Database Design for Mere Mortals

Charles Maxwood

  • VMWare Workstation
  • GoCD
  • Ruby Rogues Parley
  • Ruby Dev Summit

Chandan Jhunjhunwal     

  • Twitter @ChandanJ
  • chandan@faodailtechnology.com