Getting started with RethinkDB

Node and Rethink banner

RethinkDB is open source document based database system designed for developing real-time application. RethinkDB revolutionise the way data flows in real-time application. Generally, in order to know the changes in data we do check the database by performing polling in specific interval and if we find any changes we broadcast it to all connected nodes or specific connected nodes which we covered in these tutorials.

There are 3 important phases in real-time web application :

  1. Pull all data from model and show it to client.
  2. Keep checking for the changes in model ( Polling )
  3. If changes found notify to connected clients. ( Probably using Socket )

RethinkDB takes out step number 2 and provides us the real-time changes itself. So with RethinkDB as a model, here are the following steps we need to do build real-time web application.

  1. Pull all data from model and show to client.
  2. If there is changes, RethinkDB will notify the middle layer, broadcast them to client using Socket.

One of the biggest headache to any developer is the Step 2 only because it’s the heart of the real-time web application to know the changes in model. And if we deep down to more technical terms other than developer headache, then it puts a lot of loads to Server and latency of course increase ( By polling to Server requires various HTTP calls over Wide area network ).

Installing RethinkDB

You need to perform installation in two parts :

  • Installing RethinkDB Server.
  • Installing RethinkDB Client Driver.

RethinkDB Server is available for all major operating system, you can visit to their official website in order to know the supported platforms.

RethinkDB official client drivers are available for JavaScript, Ruby, Python, Java. There is community supported drivers available for C++, C#, R etc.

Installing in Linux (Ubuntu 14.10)

Run following command one by one to install the RethinkDB Server.

source /etc/lsb-release && echo "deb $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- | sudo apt-key add -
sudo apt-get update
sudo apt-get install rethinkdb

Install in Mac

Go to this link and download the installer file. If you have brew installed then you can directly install the RethinkDB Server in your system using following command.

brew update && brew install rethinkdb

Install in Window

Windows installer is still in beta. You can download the installer from here and follow the wizard to complete the installation.

Starting RethinkDB Server

Assuming you have installed RethinkDB in your machine. Open up new terminal and type following command to start the RethinkDB Server.


rethinkdb server

Installing Node.js driver

Start a new Node.js project and create package.json file. Recommended way to create is using

npm init

Run following command to install rethinkdb client driver.

npm install --save rethinkdb

About ReQL ( RethinkDB Query language )

ReQL query language let’s you manipulate and perform query on JSON document. Unlike other query languages, ReQL is chain-able and it embeds in programming languages. ReQL also let’s you perform sub queries over JSON document. This is rich and future of big data query processing. You can learn all the commands in details by visiting here.

Admin screen

Rethinkdb provides web administrative panel for the monitoring and management purpose. By using this web panel you can manage your server cluster, perform sharding and replication, check out logs and many more. To access the web console add following parameter when starting up rethinkdb Server.

rethinkdb --bind all

You should see following screen after executing the command.

Node and RethinkDB

Open http://localhost:8080 in your browser to access the web management console.

Node and Rethinkdb

What’s next ?

This post was intended to get you through installation and concept of RethinkDB. In next tutorial, we will be developing fully fledged real-time web application using Node and RethinkDB, so stay tuned.


RethinkDB is the future of real-time web application. With its query language, real-time feed change, scale-ability, it looks so promising. Also it is second rated in Github after Redis in database section.

5 thoughts on “Getting started with RethinkDB”

  1. rethinkdb looks totally AWESOME ! i first got excited about it very recently when i learned about “Meatier”, the replacement(?) for meteor which uses rethinkdb as the back-end instead of mongodb.

    whats really has me excited is that apparently rethinkDB does the “foreign key” relationships. OK purists, please get off my back about this. the one-to-many relationship with two or more parents exists everywhere in data modeling. mongodb looks sorta cool, but most of us need data referential integrity enforced at the db level. (sorry to offend you purists)

    shahid – can you suggest a good lite training-vid intro ?

    1. Hi Mark,

      RethinkDB is really awesome. Regarding referential integrity which is not present in Mongo or any big data software is because of the reading speed. Join slows down the system a lot and that’s why Google file system introduced this concept.

      Regarding rethinkDB, its really awesome because other than the fact that it allows you to have same feeling of referential integrity of SQL databases, it also provides chain-able queries and changes update ( i.e Push the data for real time web ).

      I have’t found any good video on it, but i am currently writing an fully fledged real time application using RethinkDB and Node.js for upcoming tutorial.

        1. Thanks for the link.

          Yes i will write about developing real time web app using RethinkDB and Node.

          1. ok but you need to understand your loyal fan base will be expecting to understand what “strongloop” is, and why we should not use it since its controlled by IBM – and/or why we need to look at RethinkDBdash instead.

            but seriously, i started looking at RethinkDB because of “Meatier”, bur from what little i have seen of RethinkdDB and ReQL, it appears that RethinkDB can almost be its own framework, and maybe something as simple as jQuery it becomes a replacement for Meteor.

            looking forward to see what you come up with !

Comments are closed.