Skip to content

Instantly share code, notes, and snippets.

alq666 / latency.txt
Created January 2, 2019 16:58 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

Keybase proof

I hereby claim:

  • I am alq666 on github.
  • I am alq ( on keybase.
  • I have a public key ASA8hZ_wc05wAyTuPgZEtwob5PP-YjIoR2A79kI0EBA2XAo

To claim this, I am signing this object:

alq666 /
Created September 12, 2016 14:32 — forked from acolyer/
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
alq666 / tcpext.gawk
Created May 25, 2016 22:04
Parse /proc/net/netstat
/TcpExt:/ {
for (i=2; i <= NF; i++) {
if (match($i, /[[:digit:]]+/)) {
values[i] = $i
} else {
keys[i] = $i
alq666 / haproxy-stats
Created May 24, 2016 14:10
HAProxy metrics
0. pxname [LFBS]: proxy name
1. svname [LFBS]: service name (FRONTEND for frontend, BACKEND for backend,
any name for server/listener)
2. qcur [..BS]: current queued requests. For the backend this reports the
number queued without a server assigned.
3. qmax [..BS]: max value of qcur
4. scur [LFBS]: current sessions
5. smax [LFBS]: max sessions
6. slim [LFBS]: configured session limit
7. stot [LFBS]: cumulative number of connections
alq666 /
Created May 6, 2016 00:33
Redact certain patterns in rsyslog
#!/usr/bin/env python
"""A message modification plugin to remove credentials
Copyright (C) 2014 by Adiscon GmbH and Peter Slavov
Copyright (C) 2016 by Datadog
This file is part of rsyslog.
Licensed under the Apache License, Version 2.0 (the "License");
From 504504f2f8c13f077f09e0906cd7e7d3ca405acc Mon Sep 17 00:00:00 2001
From: Vincent Bernat <>
Date: Wed, 7 May 2014 18:18:07 +0200
Subject: [PATCH] MINOR: dtrace: add dtrace support (WIP)
Both dtrace and systemtap are supported. Currently, only one tracepoint
is defined.
.gitignore | 1 +
Makefile | 18 +++++++++++++++++-
alq666 /
Last active April 16, 2016 03:50
Find drop packets
# Place a probe to record calls and return values of enqueue_to_backlog
sudo perf probe -a 'enqueue_to_backlog%return $retval'
# Record for 60 seconds
sudo perf record -e probe:enqueue_to_backlog -aR sleep 60
# Display calls
sudo perf script
alq666 / rto.awk
Last active March 14, 2016 21:32
Capture RTO, retransmits and lost packets into Datadog
/rto/ {
# $3 rto:xxx
# $10 unacked:x
# $11 retrans:x/y
# $12 lost:x
split($3, arr, ":");
rto = arr[2];
if (match($0, /rto:([[:digit:]]+)/, arr)) rto = arr[1];
if (match($0, /unacked:([[:digit:]]+)/, arr)) unacked = arr[1];
if (match($0, /retrans:([[:digit:]]+)?\/([[:digit:]]+)/, arr)) retrans = arr[1];
alq666 / elb_logs.sql
Last active January 19, 2016 20:14
Redshift analysis of ELB logs
CREATE TABLE elb_logs (
RequestTime DateTime encode lzo,
ELBName varchar(30) encode lzo,
RequestIP_Port varchar(50) encode lzo,
BackendIP_Port varchar(50) encode lzo,
RequestProcessingTime FLOAT encode bytedict,
BackendProcessingTime FLOAT encode bytedict,
ClientResponseTime FLOAT encode bytedict,
ELBResponseCode INTEGER encode lzo,
BackendResponseCode INTEGER encode lzo,