Skip to content

Instantly share code, notes, and snippets.

@thefotios
Last active August 25, 2016 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefotios/10889c28621c282fc2bf0bd4c7b4798e to your computer and use it in GitHub Desktop.
Save thefotios/10889c28621c282fc2bf0bd4c7b4798e to your computer and use it in GitHub Desktop.
TCP Socket Availability
/**
* 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,
})
/**
* 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,
})
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