Chapter 7. Developing Real-Time Web Applications

We've finally reached the last chapter of our introductory book to RethinkDB. It's been a long journey so far!

In the previous chapters, you learned how to administer RethinkDB and write and run queries using the ReQL language. You also learned how to administer a cluster, run queries from Node.js, and deploy RethinkDB to the cloud.

In this chapter, we're going to put everything that we've covered together; we'll understand what real-time apps are, how they work, and how to use RethinkDB's features to power a Node.js web application.

In this chapter, you will also learn about the following:

  • How to install and use the Express.js module
  • How to connect a Node.js backend to a .js frontend
  • How to use Changefeeds to push data to the client

At the end of the chapter, you'll have a perfectly working Node.js web application that you can use as a template when developing your own web apps. We'll also have a brief recap of the most important things that we've covered.

Introducing real-time web applications

In this chapter, we're going to see how we can use the tools we've covered so far to build real-time applications for the Web. However, before diving into it, one of the first questions you may want answered is, "what exactly is a real-time web application?"

A real-time web application can be defined as any kind of web-facing software that allows clients (usually users) to receive information as soon as it gets published. In other words, it's a software application that functions within a timeframe that the user senses as immediate or current. In these types of software, latency must be extremely low, usually in the range of milliseconds.

Examples of real-time web apps

You may be wondering what a real-time web app looks like. Well, chances are that you use one of them every day! Gmail is an example of a real-time web app; we've all noticed e-mails and notifications popping up on our browser in real time and an asynchronous manner without the need of refreshing the page. Twitter is another example: tweets appear as soon as they get published without the user needing to refresh the browser page. Many multiplayer online games depend on low-latency communications between individual gamers, and for this reason technologies must be used to get the data to clients in real time; so online games are another example of real-time applications. Charts and graphs have always been a great way to visualize data in a graphical manner. Now, you can have these graphs and charts connected to real-time data sources, such as a feed or a database, and you can see changes reflected on the graphs in real time. If you think about it, the possibilities are literally endless!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.107.81