Skip to content

Instantly share code, notes, and snippets.

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
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_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"
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;
};
}
interface InboundMessage {
room: string;
id: string;
data: object;
version: number;
}
ws.on('message', (rawMsg: string) => {
const messages: InboundMessage[] = JSON.parse(rawMsg);
console.log(messages);
@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:
@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',
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%