Optimizing Large File Transfers in Linux with Go - An Exploration of TCP and Syscall

As I experiment with Raspberry Pi and other devices in my network, I have created a small network application to aid in device discovery using multicast, data collection, and other functions. One key feature of this application is the ability to download various data and metrics from some plugins weekly. With file sizes ranging from 200 MB to 250 MB after applying some compression, it’s essential to carefully consider some approaches for sending these files over TCP using Go....

January 30, 2023 · 9 min · Me

A simple example of using unix domain socket in Kubernetes

In my previous post, Understanding Unix Domain Sockets in Golang, I mentioned that one potential use case for Unix domain sockets is to communicate between containers in Kubernetes. I received requests for an example of how to do this, so in this post, I’ll provide a simple example using two Go applications that you can find in this repository. Using Unix domain sockets in Kubernetes can be an effective way to communicate containers within the same pod....

December 16, 2022 · 4 min · Me

Understanding Unix Domain Sockets in Golang

In Golang, a socket is a communication endpoint that allows a program to send and receive data over a network. There are two main types of sockets in Golang: Unix domain sockets (AF_UNIX) and network sockets (AF_INET|AF_INET6). This blog post will explore some differences between these two types of sockets. Unix domain sockets, a.k.a., local sockets, are used for communication between processes on the same machine. They use a file-based interface and can be accessed using the file system path, just like regular files....

December 5, 2022 · 8 min · Me

Socket sharding in Linux example with Go

I bet there have been many times that you were working on the terminal with multiple tabs and you launched an HTTP server, and then you forgot that the server was already being executed, and then you tried to relaunch it from another tab getting the known error: go run main.go listen tcp :8080: bind: address already in use This is because we cannot open a socket with the same source address and port by default in Linux and the vast majority of operating systems....

August 21, 2021 · 6 min · Me

Implementing a simple K8s admission controller in Go

What is an admission controller? In a nutshell, Kubernetes admission controllers are plugins that govern and enforce how the cluster is used. They can be thought of as a gatekeeper that intercept (authenticated) API requests and may change the request object or deny the request altogether. The admission control process has two phases: the mutating phase is executed first, followed by the validating phase. Kubernetes admission Controller Phases: An admission controller is a piece of software that intercepts requests to the Kubernetes API server before the persistence of the object (the k8s resource such as Pod, Deployment, Service, etc…) in the etcd database, but after the request is authenticated and authorized....

March 1, 2021 · 8 min · Me