Skip to content

Twitter clone using Mongo or Redis, depending on an environment variable

Notifications You must be signed in to change notification settings

cyrusinnovation/Rails-Performance

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Rails with Various NoSQL Data Stores

The goal of this project is to learn about new tools that facilitate scalability, enhance application performance, and improve development speed. The focus, at least to start, is on back-end data stores, and particularly NoSQL solutions.

The approach is to take one or more demo applications, point them at various different back ends, and run load tests against them. The NoSQL database is used as the data store behind the model classes, which should look as much as possible like ActiveRecord classes to the outside world.

We use JMeter for load testing and Rails as the application platform.

The demo application

The current demo app is a Twitter clone forked from ujihisa's twi1 at https://github.com/ujihisa/twi1. The original app stored tweets in javascript files and only used the database for storing users; the current app has been updated to store tweets in the database as well.

The current demo app doesn't have the "follow" feature.

Starting the application requires indicating which database back-end to use in the "DB" environment variable. The current options are "Mongo" and "Redis" (case insensitive). E.g.:

> DB=MONGO rails s

The environment variable controls which gems will be selected in the Gemfile, and which model classes will be loaded.

The models

Each model class contains a conditional that loads in a file whose extension is determined by the database environment variable (i.e., user.mongo or user.redis).

The Mongo models use the Mongoid gem to mimic ActiveRecord models. The authlogic gem doesn't work with Mongo, so Nifty Generators was used to create authentication code.

The Redis models involve a lot more one-off reimplementation of ActiveRecord methods. These assume a certain naming format for keys in Redis, and various tricks to make a key-value store look like a relational database.

The performance tests

The JMeter test is included in the file "Twitter Clone Test Plan.jmx" in the JMeter directory. This can be opened and run directly from the JMeter GUI.

About

Twitter clone using Mongo or Redis, depending on an environment variable

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 80.2%
  • JavaScript 14.7%
  • Shell 5.1%