Skip to content

Instantly share code, notes, and snippets.

@matthiasr
matthiasr / 01.md
Created May 19, 2022 07:50
What makes operating databases more complex than stateless services?

To me, the fundamental difficulty in managing databases is the amount of state they have, the time it takes to move that state around, and the difficulty in keeping it in sync.

Whether it's Cassandra, MySQL, or PostgreSQL, bringing up a new instance takes time, orders of magnitude more than replacing some stateless service. Network mountable volumes help, because that state mostly lives on whatever provides that, but you still need to account for "moving" it into the cache.

Additionally, you necessarily have shared state that you cannot ever reset. A lot of the usefulness from "cattle" servers is that you have a clear way to reset them to a known good state. In most cases you cannot do that with your data.

Some of the mechanics of a cattle management system like Kubernetes still work but they're on timelines that give the cluster operators headaches.

@matthiasr
matthiasr / questions.md
Created December 3, 2021 07:38
Someone asked: How can I be less annoying to collaborate with?

A great technique that a manager set me on the path towards, and that I learned over the last years is to ask many good questions. this takes practice. a good question pushes the other person towards an insight, but lets them supply their own experiences and gives them the satisfaction of figuring something out vs. being told what to do.

For example, instead of stating "this container needs a readiness probe", you could ask "what would a good readiness probe be for this container?", or even more open "how can we make sure this gets taken out of traffic when it breaks? how can we detect that it's broken?"

I found the questioning approaches from Resilience Engineering/LFI helpful, especially to never ask why – it's always an accusation. Better questions are How and What. Sometimes it takes me a few iterations in my head to go from "Why" to "What b

@matthiasr
matthiasr / 1_intro.md
Last active May 9, 2022 14:45
Notes on operating cluster queues

Someone asked in chat (paraphrased) "I am coming from synchronous online systems, and now am going to work on a queue-based system. What should I be aware of?" This is a (somewhat freely-associated) collection of thoughts, based on my experience at SoundCloud.

@matthiasr
matthiasr / delete-s3.sh
Created December 14, 2020 09:18
Delete everything in an S3 bucket (in a hurry)
# I needed to delete ~300k objects from an S3 bucket in a hurry. The better and cheaper solution is to use a lifecycle rule, but those can take a day or two to take effect.
bucket="i-want-to-lose-all-my-data"
mkdir -p deletes
# 1. List all the objects in the bucket, transform them 1000 at a time into request objects for DeleteObjects, write each to a separate file
aws s3api list-objects-v2 --bucket "${bucket}" \
| jq -c '.Contents | _nwise(1000) | map({ Key: .Key }) | { Objects: ., Quiet: true }' \
| awk '{ f = "deletes/" NR ".json"; print $0 > f; close(f) }'
$ kubectl --namespace mr-test exec -ti hostname-test bash
root@hostname-test:/# cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.128.1.142 hostname-test
@matthiasr
matthiasr / LICENSE.md
Last active February 15, 2023 00:16
Exporting chef-client metrics to Prometheus

The MIT License (MIT)

Copyright © 2017 SoundCloud Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

@matthiasr
matthiasr / out.txt
Created October 13, 2016 17:32
Kubernetes file permissions in tarball have changed
% for v in 1.3.5 1.3.6 1.3.7 1.3.8 1.4.0 1.4.1; do echo ========= $v ==========; curl -sSfL "https://github.com/kubernetes/kubernetes/releases/download/v${v}/kubernetes.tar.gz" | tar -O -zxf - kubernetes/server/kubernetes-server-linux-amd64.tar.gz | tar -tvzf -; done
========= 1.3.5 ==========
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/
-rw-r--r-- 0 root root 3533536 Aug 11 20:35 kubernetes/LICENSES
-rw-r--r-- 0 root root 41933134 Aug 11 20:35 kubernetes/kubernetes-src.tar.gz
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/server/
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/server/bin/
-rw-r--r-- 0 root root 33 Aug 11 20:35 kubernetes/server/bin/federation-apiserver.docker_tag
-rw-r--r-- 0 root root 33 Aug 11 20:35 kubernetes/server/bin/federation-controller-manager.docker_tag
-rw-r--r-- 0 root root 104576512 Aug 11 20:35 kubernetes/server/bin/federation-apiserver.tar
#!/bin/sh
set -eufx
tmpdir=$(mktemp -d ./prometheus-1610.XXXX)
cd "${tmpdir}"
cleanup() {
set +e
@matthiasr
matthiasr / Makefile
Created January 13, 2016 15:22
Extract vendored kubernetes/kubernetes client library dependencies at build time
KUBERNETES_VERSION ?= v1.1.3
KUBERNETES_SOURCE_URL = https://github.com/kubernetes/kubernetes/archive/v$(KUBERNETES_VERSION).tar.gz
LOCAL_SOURCES := $(shell find local -type f)
.PHONY: prepare
prepare: vendor/k8s.io/kubernetes/.available vendor/k8s.io/kubernetes/.lifted_godeps $(LOCAL_SOURCES:local/%=vendor/%)
# Lift a source tree into the vendor tree, skipping Godeps
vendor/%/.available: build/$(KUBERNETES_VERSION)/%/.available

Keybase proof

I hereby claim:

  • I am matthiasr on github.
  • I am matthiasr (https://keybase.io/matthiasr) on keybase.
  • I have a public key whose fingerprint is F46A 5FAA 9508 311D DBCC 403A 9A7D 111C AE60 D44B

To claim this, I am signing this object: