Book Image

Building Scalable Apps with Redis and Node.js

By : Joshua Johanan
Book Image

Building Scalable Apps with Redis and Node.js

By: Joshua Johanan

Overview of this book

Table of Contents (17 chapters)
Building Scalable Apps with Redis and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Redis is for application state


Redis is most useful when it is used to keep track of a temporary application state. A perfect example of this is a session. It is only needed when a user is logged in. We store it in Redis, so that it can be easily retrieved and accessible to multiple processes on multiple machines. Redis helps us follow the rule of scalability of never keeping application state locally. Any data that will be needed in multiple requests should be kept in Redis.

Another thing to keep in mind about Redis is that it is only for short term data. Anything that is needed to be stored for a long time should be in a database. Your user table, every time a user logs in, and all tracking information are things that you would keep in a database instead of Redis.

Our application is now ready to store our state in Redis. We have built all the functions that we will use to interact with Redis. All of this interaction is going to happen through Socket.IO. We will be building this part of the...