pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

Events/SSEs with 2/2+ instances don't properly get handled or responded

Open saifali96 opened this issue 7 years ago • 0 comments

What's going wrong?

While using pm2 with multiple (2 || 2+) instances on Heroku with a express.js application implementing SSE (Server Sent Events), only half of the events are emitted or sent to the client. While if we bring down the instance number to 1, everything seems to work fine!

How could we reproduce this issue?

Run any SSE example code on node.js/express.js on Heroku/elsewhere with pm2 with 2 instances.

Supporting information

We are building an API that implements SSEs, which sends an event everytime there's an internal event emitted, for example order.placed and then sends an event stream to the client that is subscribed to this eventstream.

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Tue Jun 25 2019 15:58:25 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.5.1
node version         : 12.4.0
node path            : /app/.heroku/node/bin/pm2
argv                 : /app/.heroku/node/bin/node,/app/.heroku/node/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : undefined
uid                  : 49214
gid                  : 49214
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.5.1
node version         : 12.4.0
node path            : /app/.heroku/node/bin/pm2
argv                 : /app/.heroku/node/bin/node,/app/.heroku/node/bin/pm2,report
argv0                : node
user                 : undefined
uid                  : 49214
gid                  : 49214
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
cpus nb              : 8
freemem              : 8877875200
totalmem             : 64424677376
home                 : /app
===============================================================================
--- PM2 list -----------------------------------------------
┌──────┬────┬──────┬────────┬───┬─────┬────────┐
│ Name │ id │ mode │ status │ ↺ │ cpu │ memory │
└──────┴────┴──────┴────────┴───┴─────┴────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/app/.pm2/pm2.log last 20 lines:
PM2        | 2019-06-25T15:58:25: PM2 log: ===============================================================================
PM2        | 2019-06-25T15:58:25: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2019-06-25T15:58:25: PM2 log: Time                 : Tue Jun 25 2019 15:58:25 GMT+0000 (Coordinated Universal Time)
PM2        | 2019-06-25T15:58:25: PM2 log: PM2 version          : 3.5.1
PM2        | 2019-06-25T15:58:25: PM2 log: Node.js version      : 12.4.0
PM2        | 2019-06-25T15:58:25: PM2 log: Current arch         : x64
PM2        | 2019-06-25T15:58:25: PM2 log: PM2 home             : /app/.pm2
PM2        | 2019-06-25T15:58:25: PM2 log: PM2 PID file         : /app/.pm2/pm2.pid
PM2        | 2019-06-25T15:58:25: PM2 log: RPC socket file      : /app/.pm2/rpc.sock
PM2        | 2019-06-25T15:58:25: PM2 log: BUS socket file      : /app/.pm2/pub.sock
PM2        | 2019-06-25T15:58:25: PM2 log: Application log path : /app/.pm2/logs
PM2        | 2019-06-25T15:58:25: PM2 log: Process dump file    : /app/.pm2/dump.pm2
PM2        | 2019-06-25T15:58:25: PM2 log: Concurrent actions   : 2
PM2        | 2019-06-25T15:58:25: PM2 log: SIGTERM timeout      : 1600
PM2        | 2019-06-25T15:58:25: PM2 log: ===============================================================================

saifali96 avatar Jun 25 '19 15:06 saifali96