[Answered ]-Django and Rails with one common DB

2👍

For my startup, we also needed to put out a full fleshed website along with an API. We are also using DynamoDB for storing most of the data and are only using MySQL for session info.

I opted to use Ruby on Rails for the Webapp and Sinatra for the API. If you’re criteria is simply learning as many new things as possible, then it would make sense to opt for relatively different stacks (django/python and RoR). In our case, we went with sinatra because it’s essentially a very lightweight wrapper around Rack and perfect for an API which essentially receives requests, calls one or more services or does some processing and hands out a formatted response. While I don’t see any problem with using python/django instead of sinatra, in our case the benefit was having to spend less time working with a different language.

Also, scalability in rails is a bit of an iffy subject. In the end, it’s about how you use it. We’ve had no issues scaling rails with unicorn and nginx. Our business logic is all in the API service and the rails server as well uses the API for most of the work. This means we don’t use active record on rails and the website is just another consumer for our API which does all the heavy lifting whether the request comes from an app or the website. Using MySQL for the session store ensures we can route requests to any of the application servers without having to worry about always routing requests from the same client to the same server every time. This allows us to ramp up and down easily only considering the amount of traffic we’re getting.

At the time we started working on this, there wasn’t an ORM for dynamo db which looked and felt just like active record, so we ended up writing a few high level classes of our own to handle storage and retrieval of models on DynamoDb. Considering DynamoDB is not tailored for scans or joins, this didn’t take a lot of effort since we were almost always doing lookups based on keys and ranges. This meant we didn’t really need a replacement for active record since the real strength of active record is being able to intuitively do joins, etc. by convention.

DynamoDB does have it’s limitations though and you might find yourself in situations where you will need to scan a large number of records. In our case, we also use CloudSearch to index some important info and use it as a fallback for cases when we need to do text based searches which need to scan all our data.

👤Nikhil

Leave a comment