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 :
- Pull all data from model and show it to client.
- Keep checking for the changes in model ( Polling )
- 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.
- Pull all data from model and show to client.
- 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 ).
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.
Installing in Linux (Ubuntu 14.10)
Run following command one by one to install the RethinkDB Server.
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.
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.
Installing Node.js driver
Start a new Node.js project and create package.json file. Recommended way to create is using
Run following command to install rethinkdb client driver.
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.
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.
You should see following screen after executing the command.
Open http://localhost:8080 in your browser to access the web management console.
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.