Skip to content

Instantly share code, notes, and snippets.

Round-robin Least Outstanding Requests Performance Improvement
Median 68.5 54.7 25.23%
P95 1062.4 217.2 389.13%
P99 2374 386.4 514.39%
@simontabor
simontabor / lor-test.js
Last active March 31, 2020 17:05
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',
@simontabor
simontabor / artillery.yml
Last active March 31, 2020 14:12
Artillery load test
config:
target: ""
phases:
- duration: 120
arrivalRate: 10
scenarios:
- flow:
- loop:
- get:
interface InboundMessage {
room: string;
id: string;
data: object;
version: number;
}
ws.on('message', (rawMsg: string) => {
const messages: InboundMessage[] = JSON.parse(rawMsg);
console.log(messages);
interface MessageAction {
action: 'subscribe' | 'unsubscribe';
message: {
// Which room to subscribe to or unsubscribe from
room: string;
// Whether to "dump" existing messages for this room
dump: boolean;
};
}
resource "aws_cloudwatch_metric_alarm" "alb_error_rate" {
alarm_name = "${aws_lb.main.name}-alb-error-rate"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2
threshold = 5
alarm_description = "Load balancer error rate has exceeded 5%"
treat_missing_data = "notBreaching"
metric_query {
id = "error_rate"
resource "aws_route53_health_check" "latency" {
type = "CLOUDWATCH_METRIC"
cloudwatch_alarm_name = "${aws_cloudwatch_metric_alarm.latency.alarm_name}"
cloudwatch_alarm_region = "${var.region}"
insufficient_data_health_status = "Healthy"
tags = {
Name = "high-latency"
}
}
resource "aws_route53_record" "latency-use1" {
zone_id = "${data.aws_route53_zone.my_zone.zone_id}"
name = "my-application"
type = "A"
set_identifier = "service-us-east-1"
alias {
zone_id = "${aws_lb.main_us_east_1.zone_id}"
name = "${aws_lb.main_us_east_1.dns_name}"
evaluate_target_health = true
@simontabor
simontabor / wixTracker.html
Last active September 3, 2015 17:09
GoSquared Tracking for Wix sites (add as an iFrame widget then replace YOUR-SITE-TOKEN on line 10 with your site token)
<html>
<head>
<script src="//sslstatic.wix.com/services/js-sdk/1.43.0/js/wix.min.js"></script>
<script>
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
insertBefore(d,q)}(window,document,'script','_gs');
_gs('YOUR-SITE-TOKEN', false);
@simontabor
simontabor / liveBalance-slot-order.js
Created February 19, 2015 15:01
Ordering of slot movements based on `liveBalance` parameter
[ { from: '11.11.12.71:6381', to: '11.11.12.70:6380', slot: 6553 },
{ from: '11.11.12.72:6381', to: '11.11.12.71:6381', slot: 9829 },
{ from: '11.11.12.72:6381', to: '11.11.12.70:6381', slot: 10922 },
{ from: '11.11.12.71:6380', to: '11.11.12.72:6381', slot: 16383 },
{ from: '11.11.12.70:6381', to: '11.11.12.72:6381', slot: 13321 },
{ from: '11.11.12.72:6381', to: '11.11.12.70:6381', slot: 10921 },
{ from: '11.11.12.70:6381', to: '11.11.12.72:6381', slot: 13109 },
{ from: '11.11.12.72:6381', to: '11.11.12.70:6381', slot: 10920 },
{ from: '11.11.12.70:6381', to: '11.11.12.72:6381', slot: 13110 },
{ from: '11.11.12.72:6381', to: '11.11.12.70:6381', slot: 10919 },