Potential Performance Issue with Heartbeat Scheduling in socket.io-adapter with Redis #5306
Unanswered
csethanhcong
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi! From my understanding, the That being said, calling the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are using socket.io-adapter with Redis as the backend for multiple API servers. While analyzing the behavior of serverSideEmit, we noticed the following code snippet in
cluster-adapter.js
:Observations:
Every time serverSideEmit is called, it triggers publish, which in turn calls scheduleHeartbeat().
If the server emits messages frequently, heartbeats will be continuously scheduled.
We use serverSideEmit to update user online/offline status.
With 10k concurrent users (CCU), online/offline updates are frequent, causing heartbeats to be queued repeatedly.
Over time, this behavior may lead to high CPU usage due to excessive heartbeat scheduling.
Question:
Is this the intended design? Or is there a mechanism that prevents excessive heartbeats from affecting performance?
Would appreciate any insights on optimizing this behavior or mitigating potential CPU spikes due to unnecessary heartbeat scheduling.
Beta Was this translation helpful? Give feedback.
All reactions