Skip to content

Instantly share code, notes, and snippets.

@simontabor
Last active March 31, 2020 17:05
Show Gist options
  • Save simontabor/8bbb4fa993816870b8e263736a5094c6 to your computer and use it in GitHub Desktop.
Save simontabor/8bbb4fa993816870b8e263736a5094c6 to your computer and use it in GitHub Desktop.
Simple HTTP server to run a load test against
const http = require('http');
http.createServer((req, res) => {
if (req.method === 'POST') {
let now = Date.now();
const finish = now + Math.random() * 200;
while (now < finish) {
now = Date.now();
}
res.writeHead(200, {
'Content-Type': 'application/json',
});
res.end(JSON.stringify({ success: true }));
}
if (req.method === 'GET') {
res.writeHead(200, {
'Content-Type': 'application/json',
});
res.end(JSON.stringify({ success: true }));
}
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment