'NodeJS WebSocket Instance Warmup
While scaling out the azure instance at a high load, many WebSocket requests are not handled properly as these instances are not warmed up. To pre-warm up the instance, we have added a piece of code in the listening function in the WebSocket. In this code, we are trying to create multiple WebSocket connections to the same instance for the warmup of the machine in order to prepare the instance to handle a high load. But we are not able to establish these WebSocket connections to the same machine in the Azure app service while we could make WebSocket connections to the same machine in the local machine. Really appreciate it if anyone could guide us on this.
function onListening() {
//psuedo code for warming up the instances quickly//
for (let warmupIndex = 0; warmupIndex < 20; warmupIndex++) {
let ws = new WebSocket('ws://' + os.hostname() + ':'+ port+'/');
setTimeout(function () {
logger.infoLog("Inside timeout")
ws.close();
}, 10000);
}
callback(null);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
