Question
BUPA
AU
Last activity: 5 May 2016 12:57 EDT
How Pega CHAT can connect to MongoDB replica set?
Hi,
We have created MongoDB replica set where 2 Mongo DB instances are running in different VM one as Primary and one as secondary. In the Pega CHAT Config.json file we only have option to mention the connection details for Primary MongoDB. Please let us know how Pega CHAT can connect to the replica set to support the automatic failover meaning if Primary goes down then Pega CHAT will automatically get connected with secondary and work as it is.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
I have not tried myself, but by reading the mongodb documentation, it appears that you could use mongodb.replicaSet as the key with the value as the replica set name.
BUPA
AU
Can you please suggest how the config.json value will be? Where we should provide the replica set name in the connection json object?
"mongodb" : {
"host" : "localhost",
"db" : "PEGA_CHAT",
"port" : 27017,
"user" : "PEGA_CHAT",
"password" : "f0d_devteam"
},
BUPA
AU
Also, please let me know how to set the automatic rollover session using the below setting in config.json file.
"mongodb" : {
"host" : "localhost",
"db" : "PEGA_CHAT",
"port" : 27017,
"user" : "PEGA_CHAT",
"password" : "f0d_devteam",
"replicaSet": "rs0"
},
Pegasystems Inc.
US
do you mean automatic failure? My understanding is that it should be taken care of by replicaSet automatically on the db server side: https://docs.mongodb.org/manual/core/replica-set-high-availability/
BUPA
AU
I know, but in the config.json file we are binding chat server with a specific mongo db instance by specifying the hostname and port. If the host goes down the pega chat is stopped working even if we have a secondary mongodb instance running one different host/same host but diffrent port.
Pegasystems Inc.
US
I wonder if you can simply add hosts like "host1","host2"... same as port. Dan Shipper can you confirm one way or another?
BUPA
AU
Hi Dan
Please help us here. Please also let me know how we can enter some authorisation token into socket.io header while client snippet establishes the connection with the chat server?
BUPA
AU
Adding Brett Allen to join this discussion and help. Thanks.
Pegasystems Inc.
US
Hi guys - this isn't a straightforward question unfortunately. Looping in Justin Meltzer, Piotr Struzik and Piotr Bis who may be able to help..
Updated: 24 Apr 2016 16:17 EDT
Pegasystems Inc.
PL
Hi
There are multiple approaches probably
The way I configured replica set in EU is:
Pega CHAT app has only 1 adres (url) which should always point to the primary node of replica set
On all replica set nodes there are scripts who check which one is the primary and in case it changes (some other node will be elected to be primary) the url will get updated
From what i understand about replica sets in mongodb the must be at least 3 nodes to have HA because there must be at least 2 to elect a new primary
So if you have only 2 nodes then if the primary will go down your secondary won't get elected to primary automatically , you will need to force it manually
If you will put secondary nodes in the app config you will still need to do some checks to see which one of them has been elected to be primary
I think it will be easier to have only 1 url in the config and just make sure it points to primary this will give us more flexibility in changing replica set configuration (ex. adding new replica set nodes)
Any approach we take there will always be some disruption in service because it takes replica set some time (up to 20 s) to elect a new primary
BUPA
AU
Thanks for your reply. You have mentioned that if the primary gets changed then the URL will get updated. >> 1. Is this the URL mentioned in config.json file? If so, then how will this be updated automatically? If updated somehow it will require a server restart and which will have its own downtime?
However the be the configuration is (2/3 repl set) we are concerned about the config.json file. If the node mentioned in that file goes down then how automatically other node will work without any disruption in the service? Please give us an example of the configuration you have done in EU. Thanks.
Tagged: Sathish Arumugam,
Updated: 26 Apr 2016 6:03 EDT
Pegasystems Inc.
PL
To clarify how it works
We have a dns record ex. primary.mongodb.example.com this should always resolve to the ip of mongodb replica set primary node
On all replica set nodes there is a custom script that runs every minute that connects to mongodb and checks which node is the primary
If the primary node changes than this scripts connects to the dns server and updates the ip to which this primary.mongodb.example.com points to
So in jcon.config you only put this url primary.mongodb.example.com and the infrastructure makes sure that when you resolve this url you will get the current primary node ip
Regarding
"If the node mentioned in that file goes down then how automatically other node will work without any disruption in the service" there will be a short distruption of service consisting of 2 things
1. Time that is needed for mongodb to elect a new node (it can take from couple of seconds to 20s)
2. Time the script takes to find out that a new primary node is elected and to update the dns (script execution time is under 2s but it's run every minute so if the primary node changes ex. 10:10:30 the script will pick it up at 10:11:00 )
worst case scenario there will be a 90s disruption in mongodb availability
"If updated somehow it will require a server restart and which will have its own downtime"
To clarify how it works
We have a dns record ex. primary.mongodb.example.com this should always resolve to the ip of mongodb replica set primary node
On all replica set nodes there is a custom script that runs every minute that connects to mongodb and checks which node is the primary
If the primary node changes than this scripts connects to the dns server and updates the ip to which this primary.mongodb.example.com points to
So in jcon.config you only put this url primary.mongodb.example.com and the infrastructure makes sure that when you resolve this url you will get the current primary node ip
Regarding
"If the node mentioned in that file goes down then how automatically other node will work without any disruption in the service" there will be a short distruption of service consisting of 2 things
1. Time that is needed for mongodb to elect a new node (it can take from couple of seconds to 20s)
2. Time the script takes to find out that a new primary node is elected and to update the dns (script execution time is under 2s but it's run every minute so if the primary node changes ex. 10:10:30 the script will pick it up at 10:11:00 )
worst case scenario there will be a 90s disruption in mongodb availability
"If updated somehow it will require a server restart and which will have its own downtime"
I can either create a script that automatically restarts CHAT service if i see errors (ex. mongodb connection failure ) in the logs or the app itself if it fails to connect to mongodb can automatically retry each time resolving the mongodb url from config.json
BUPA
AU
Thanks for your reply.
The custom script you have mentioned in your reply (custom script that runs every minute that connects to mongodb) >> is it written by you or available as a part of mongodb setup or is it a part of Pega CHAT Software?
Tagged: Sathish Arumugam, Parshant Sharma
Pegasystems Inc.
PL
Written by me because it also uses Amazon route53 api
We use Amazon route53 as the dns server
BUPA
AU
Thanks for your response. Can you please share the script you have used for our understanding? Also, where do we need to put the script? Inside mongodb or pegachat?
Accenture Australia Pty Limited
AU
Hi Piotr Struzik/ Dan Shipper,
So what we are saying is the Pega application team has to right a MongoDB script to listen to the mongoDB replica set and update the DNS alias to point to correct ip.
However, as part of PegaCHAT installation notes, https://docs-previous.pega.com/premises-chat-server-installation,
"To achieve a fault tolerant infrastructure with no single point of failure, it is recommended that you install the Pega Chat service as a multi server setup with each Node.js based chat server configured to interact with a MongoDB replica set setup and a Redis master slave setup"
And this configuration does not work out-of-the-box.
Could you please help us here and provide us the custom mongoDB sample scripts which we can work on top of and reuse if possible or provide some other solution to make this configuration work. Many thanks!