Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Redis pub/ sub vs node event emitter

Redis pub/ sub vs node event emitter

Problem

I'm not sure I understand the difference really between using Redis pub/ sub and using node/ express' event emitter. Does the pub/sub interact with my database in any way? In what cases would I use one over the other?

Problem courtesy of: Omid Ahourai

Solution

Redis allows you to build fast and powerful inter-process communication. Redis pub/sub uses your Redis process to deliver your messages, but it newer affects the data stored in Redis DB.

Event emitter works only within the single node process. So, even if you have a single node cluster, events, emitted by one worker, wont be visible to another.

Hence, event emitter is the perfect choice for within-the-process communication. But if you need inter-process communication, you should use Redis.

Solution courtesy of: Leonid Beschastny

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Redis pub/ sub vs node event emitter

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×