February 20, 2024 | 00:00

Kubernetes Downward API

Sometimes you want to expose information about the constraints the container is running without duplicating values or have the application reach out to the Kubernetes API. The Downward API helps with this problem where you can inject pod information to the container via env variables. For example, let’s imagine we want to set the GOMAXPROCS depending on the CPU limit: apiVersion: v1 kind: Pod metadata: name: my-app spec: containers: - name: my-app image: golang resources: requests: memory: "32Mi" cpu: "125m" limits: memory: "64Mi" cpu: "250m" env: - name: GOMAXPROCS valueFrom: resourceFieldRef: containerName: my-app resource: limits. Read more

January 22, 2024 | 00:00

journald RateLimitBurst

Whilst reading An overview of Cloudflare’s logging pipeline, it mentioned that it uses Journald for managing logs on the Linux VM, it mentioned both RateLimitBurst and RateLimitInterval. RateLimitBurst: Number of messages processed in a burst. RateLimitInterval: The window during which the rate limit is applied. For example, the configuration below says that we can log 5 messages every 10 seconds, any more will be dropped. RateLimitBurst=5 RateLimitInterval=10s Why would we want to rate limit logs: Read more

October 20, 2021 | 00:00

System Performance - Chapter 4

When reading the Systems Performance: Enterprise and the Cloud, 2nd Edition (2020) by Brendan Gregg, I saw that each chapter has an Exercises section with a set of questions. This series of blogs will be my attempt to answer them and also give additional links I’ve read whilst reading the chapter. The answers might not be correct, not detailed but this is to help me explain what I learned to make sure I understand it. Read more

October 13, 2021 | 00:00

System Performance - Chapter 3

When reading the Systems Performance: Enterprise and the Cloud, 2nd Edition (2020) by Brendan Gregg, I saw that each chapter has an Exercises section with a set of questions. This series of blogs will be my attempt to answer them and also give additional links I’ve read whilst reading the chapter. The answers might not be correct, not detailed but this is to help me explain what I learned to make sure I understand it. Read more

October 4, 2021 | 00:00

System Performance - Chapter 2

When reading the Systems Performance: Enterprise and the Cloud, 2nd Edition (2020) by Brendan Gregg, I saw that each chapter has an Exercises section with a set of questions. This series of blogs will be my attempt to answer them and also give additional links I’ve read whilst reading the chapter. The answers might not be correct, not detailed but this is to help me explain what I learned to make sure I understand it. Read more

September 13, 2021 | 06:38

What is MTU

Maximum transmission unit (MTU) is the max number of bytes of a data packet that a device can accept. The max size of MTU size is 1500 bytes. What happens when the packet is larger than MTU If the packet is larger than a specified MTU for a specific device it will be dropped off or fragmented into chunks. The packet is fragmented by the sender and adds certain fields in the IP header to indicate that the packet is fragmented. Read more
#TIL | #Go

July 3, 2021 | 11:38

go tool dist list

Imagine that you want to cross-compile your Go binary from your Mac for a Linux machine that runs on arm64 architecture. With Go, it’s a matter of specifying the GOOS and GOARCH environment variables for go build command. GOOS=linux GOARCH=arm64 go build main.go You don’t always know/remember what values for GOOS and GOARCH or you are not even sure if Go supports the target you desire. This is where the command go tool dist list comes in handy, when you run it it will list all the GOOS/GOARCH combinations available for the Go version that you are running. Read more

May 28, 2021 | 04:50

Go Performance Tools Cheat Sheet

Go has a lot of tools available for you to understand where your application might be spending CPU time or allocating memory. I don’t use these tools daily so I always end up searching for the same thing every time. This post aims to be a reference document for everything that Go has to provide. We’ll be using https://gitlab.com/steve-blog/go-performance-tools-cheat-sheet as a demo project and there are 3 implementations of the same thing, one more performant than the other. Read more

April 3, 2021 | 00:00

import "context"

What can you do when you import "context" inside of your go project? Looking at the source code it’s a fairly small package and provides a small api. We also see this package imported almost everywhere and the standard library also uses it. context provides the following functionality: Cancellation Context scope values Deadlines/Timeouts There are two things that you need to keep in mind when you are using context: The context. Read more

August 16, 2020 | 19:17

Deploy long-running tasks on Kubernetes

Whilst reading this extremly detailed and well written article about how graceful shutdowns work on Kubernetes. It touched on the subject of long running tasks. When we update the deployment inside of Kubernetes, it will start by deleting a pod with the old version of the image, and starts a new pod with the new version. The pod can be attached to a service it might be the case that the pod is removed from the service before the process/pod has finished. Read more