Search code examples
node.jsload-balancingeventemitter

Nodejs EventEmitter & load balancing


I heard someone says 'EventEmitter becomes an issue the moment you decide to load balance. I haven’t used it in 4 or 5 years because I’m always clustering my Node apps'

Is there a relationship between 'EventEmitter' and 'load balance'? Is it true?


Solution

  • You must be confused about something. An EventEmitter is just a tool used for letting people subscribe to notifications/events and for sending notifications/events to the subscribers of that particular event. Lots and lots of node.js objects use `EventEmitters and its interface. It really has nothing to do with load balancing.

    For example, an HTTP request object, an HTTP server and a socket object are all derived from an EventEmitter. So, lots of things you would do in node.js use EventEmitters all the time.

    Is there a relationship between 'EventEmitter' and 'load balance'?

    No, there is not.