title: Routing MQTT protocol to PM2
body: <p>We have some sort of devices connected to a <code>MQTT Broker (mosquitto)</code>, publishing some events. We want to capture all these events through a <code>node</code> application. One simple solution is to create a <code>node</code> app as a client which is connected to <code>MQTT Broker</code> and listen for every event and do an specific job for them. But in scalability point of view, if we want to scale our <code>node</code> app, we have to run multiple instance of our <code>node</code> app and use a <code>PM2</code> as a load balancer. But the problem is when we create more than one instance, all instances receive the same event and for that specific event, all instances do the same job multiple time as the number of instances we have.</p>
  
  <p>How can we route all <code>MQTT</code> events to <code>PM2</code> load balancer?</p>