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

Using Redis as a message queue


In addition to being a super-fast data store, Redis also does message queuing! We just spent the previous chapter covering message queues, so we don't have to cover the reason as to why we should use them. We will only cover how Redis uses them.

Redis's message queuing is much simpler than RabbitMQ. RabbitMQ has many different types of exchanges, queues, protocols, and many other features that Redis does not try to match. Redis is super simple message sending. The method we are using here is publish/subscribe. Redis can also do simple message queuing like RabbitMQ, using RPOPLPUSH. Redis Pub/Sub broadcasts published messages with anyone that is currently subscribed. It does not actually queue the messages. This is an important point to keep in mind. When we built our RabbitMQ workers, we would create persistent exchanges and queues so that any message sent would have somewhere to go.

Even if there were no workers, eventually every message in a RabbitMQ queue...