From 80f8f2465ec99e0c06b8e9c74bdc558f5f91a6e6 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 11 Jul 2019 11:10:33 +0100 Subject: [PATCH 1/2] remove unused pubsub client --- services/real-time/app/coffee/DocumentUpdaterController.coffee | 2 +- services/real-time/app/coffee/WebsocketLoadBalancer.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/real-time/app/coffee/DocumentUpdaterController.coffee b/services/real-time/app/coffee/DocumentUpdaterController.coffee index b3706f47ba..a7d174cace 100644 --- a/services/real-time/app/coffee/DocumentUpdaterController.coffee +++ b/services/real-time/app/coffee/DocumentUpdaterController.coffee @@ -11,7 +11,7 @@ MESSAGE_SIZE_LOG_LIMIT = 1024 * 1024 # 1Mb module.exports = DocumentUpdaterController = # DocumentUpdaterController is responsible for updates that come via Redis # Pub/Sub from the document updater. - rclientList: RedisClientManager.createClientList(settings.redis.pubsub, settings.redis.unusedpubsub) + rclientList: RedisClientManager.createClientList(settings.redis.pubsub) listenForUpdatesFromDocumentUpdater: (io) -> logger.log {rclients: @rclientList.length}, "listening for applied-ops events" diff --git a/services/real-time/app/coffee/WebsocketLoadBalancer.coffee b/services/real-time/app/coffee/WebsocketLoadBalancer.coffee index 10f0c0c646..6de7b7c4e7 100644 --- a/services/real-time/app/coffee/WebsocketLoadBalancer.coffee +++ b/services/real-time/app/coffee/WebsocketLoadBalancer.coffee @@ -7,7 +7,7 @@ HealthCheckManager = require "./HealthCheckManager" module.exports = WebsocketLoadBalancer = rclientPubList: RedisClientManager.createClientList(Settings.redis.pubsub) - rclientSubList: RedisClientManager.createClientList(Settings.redis.pubsub, Settings.redis.unusedpubsub) + rclientSubList: RedisClientManager.createClientList(Settings.redis.pubsub) emitToRoom: (room_id, message, payload...) -> if !room_id? From e632f9f29d3a3ebaf7a8893923456dd22fa1d3e3 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 11 Jul 2019 11:11:11 +0100 Subject: [PATCH 2/2] only create per-client metrics when there are multiple redis clients --- .../app/coffee/DocumentUpdaterController.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/real-time/app/coffee/DocumentUpdaterController.coffee b/services/real-time/app/coffee/DocumentUpdaterController.coffee index a7d174cace..ddd5702b54 100644 --- a/services/real-time/app/coffee/DocumentUpdaterController.coffee +++ b/services/real-time/app/coffee/DocumentUpdaterController.coffee @@ -21,9 +21,12 @@ module.exports = DocumentUpdaterController = metrics.inc "rclient", 0.001 # global event rate metric EventLogger.debugEvent(channel, message) if settings.debugEvents > 0 DocumentUpdaterController._processMessageFromDocumentUpdater(io, channel, message) - do (i) -> - rclient.on "message", () -> - metrics.inc "rclient-#{i}", 0.001 # per client event rate metric + # create metrics for each redis instance only when we have multiple redis clients + if @rclientList.length > 1 + for rclient, i in @rclientList + do (i) -> + rclient.on "message", () -> + metrics.inc "rclient-#{i}", 0.001 # per client event rate metric _processMessageFromDocumentUpdater: (io, channel, message) -> SafeJsonParse.parse message, (error, message) ->