This application was designed to test the response time for searches using Redis, PostgreSQL and Elasticsearch.
I guess you know about Elasticsearch, if not you can read about it here.
Well... most of the time I work on projects with Rails and the client sometimes ask me if I can add Elasticsearch to make a query for some or multiple fields or whatever reason and I know the power of Elasticsearch has but I always asked myself if there is any difference of time using ActiveRecord or Elasticsearch if the query is not to complex and the DB isn't to big (I'm going to say: big is over a million of lines in a table). To resolve this question I created this application but why Redis? Well if I'm comparing an SQL DB against the Elasticsearch service why not add an NoSQL DB and test everything, right?.
To connect with databases I have selected the most commonly used ORM:
- ActiveRecord for PostgreSQL.
- Ohm for Redis.
For Elasticsearch I used the service.
To use ActiveRecord without Rails I followed this repository.
For the application I used Cuba, because it's a microframework for Ruby and just needed to create a pair of endpoints.
To load the DBs and Elasticsearch with data I have a file with information to create 929 posts. You can use a task to load that data.
rake db:seed
- The file used for this purpose was taken from elasticsearch-rails repository.
The posts have a Title, Author, Abstract, Shares, Content, Likes and Views.
You need to create the DB and run the migrations, to do that tthere is two task as the same way you use in Rails
rake db:create
rake db:migrate
even if you want to drop the DB you can run:
rake db:drop
You need to have installed PostgreSQL, Redis and Elasticsearch. After you have everything installed and running you need to run the tasks in the Rakefile.
- To create the database using ActiveRecord: rake db:create
- To run the migrations for ActiveRecord: rake db:migrate
- To load the DBs with data: rake db:seed
Done!. You have in Redis, PostgreSQL and Elasticsearch all the data.
