This Gist was automatically created by Carbide, a free online programming environment.
Last active
August 25, 2016 20:10
-
-
Save thefotios/10889c28621c282fc2bf0bd4c7b4798e to your computer and use it in GitHub Desktop.
TCP Socket Availability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* These values apply to 6 hosts running 24 node procs (the difference for 64 is negligible) | |
* It also assumes that there is no HTTP/1.1 keep-alive, so we're using 2 sockets per request (LB -> nginx -> node) | |
*/ | |
import { calcThroughput, sharedValues } from './helpers.js'; | |
const hosts = 6; ///Number of hosts in the cluster | |
const processes = 24; ///Number of node processes per host | |
calcThroughput({ | |
hosts, | |
minRange: sharedValues.minRange, | |
maxRange: sharedValues.maxRange, | |
persistentConnections: { | |
incomingConnections: hosts * processes, | |
outgoingConnections: (hosts - 1) * processes, | |
}, | |
portsPerRequest: 2, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* These values apply to 6 hosts running 24 node procs (the difference for 64 is negligible) | |
* It assumes that there is HTTP/1.1 keep-alive, so we're using persistent connections from (LB -> nginx -> node) | |
* and not creating new connections per request | |
*/ | |
import { calcThroughput, sharedValues } from './helpers.js'; | |
const hosts = 3; ///Number of hosts in the cluster | |
const processes = 64; ///Number of node processes per host | |
calcThroughput({ | |
hosts, | |
minRange: sharedValues.minRange, | |
maxRange: sharedValues.maxRange, | |
persistentConnections: { | |
incomingConnections: hosts * processes, | |
outgoingConnections: (hosts - 1) * processes, | |
nginxConnections: 2, | |
a10NginxConnections: 1, | |
}, | |
portsPerRequest: 0, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const calcThroughput = ({ hosts, minRange, maxRange, persistentConnections, portsPerRequest = 0} = {}) => { | |
console.log({persistentConnections}) | |
let numPersistentConnections = 0; | |
for (var key in persistentConnections) { | |
let val = persistentConnections[key] | |
console.log({key, val}) | |
numPersistentConnections += val; | |
} | |
const maxPorts = maxRange - minRange + 1; | |
const availablePorts = maxPorts - numPersistentConnections; | |
const maxRequestsPerHost = portsPerRequest ? Math.floor(availablePorts / portsPerRequest) : availablePorts; | |
const serviceThroughput = maxRequestsPerHost * hosts; | |
return serviceThroughput; | |
} | |
export const sharedValues = { | |
minRange: 32768, | |
maxRange: 61000, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment