Faster Protocol Buffer Serialization

Performance is key when building streaming gRPC services. When you’re trying to maximize throughput (e.g. messages per second) benchmarking is essential to understanding where the bottlenecks in your application are. However, as a start, you can pretty much guarantee that one bottleneck is going to be the serialization (marshaling) and deserialization (unmarshaling) of protocol buffer messages. We have a use case where the server does not need all of the information in the message in order to process the message....

May 3, 2023 · 4 min · 642 words · Benjamin Bengfort

Go Closures & Interfaces

Strict typing in the Go programming language provides safety and performance that is valuable even if it does increase the verbosity of code. If there is a drawback to be found with strict typing, it is usually felt by library developers who require flexibility to cover different use cases, and most often appears as a suite of type-named functions such as lib.HandleString, lib.HandleUint64, lib.HandleBool and so on. Go does provide two important language tools that do provide a lot of flexibility in library development: closures and interfaces, which we will explore in this post....

February 23, 2021 · 18 min · 3688 words · Benjamin Bengfort

New Hugo Theme

A facelift for Libelli today! I moved from Jekyll to Hugo for static site generation, a move that has been long overdue — and I’m very happy I’ve done it. Not only can I take advantage of a new theme with extra functionality (PaperMod in this case) but also because Hugo is written in Go, I feel like I have more control over how the site gets generated. A lot has been said on this topic, if you’re thinking about migrating from Jekyll to Hugo, I recommend Sara Soueidan’s blog post — the notes here are Libelli specific and are listed here more as notes than anything else....

January 24, 2021 · 3 min · 626 words · Benjamin Bengfort

Streaming Remote Throughput

In order to improve the performance of asynchronous message passing in Alia, I’m using gRPC bidirectional streaming to create the peer to peer connections. When the replica is initialized it creates a remote connection to each of its peers that lives in its own go routine; any other thread can send messages by passing them to that go routine through a channel, replies are then dispatched via another channel, directed to the thread via an actor dispatching model....

September 11, 2018 · 3 min · 584 words · Benjamin Bengfort

Synchronization in Write Throughput

This post serves as a reminder of how to perform benchmarks when accounting for synchronized writing in Go. The normal benchmarking process involves running a command a large number of times and determining the average amount of time that operation took. When threads come into play, we consider throughput - that is the number of operations that can be conducted per second. However, in order to successfully measure this without duplicating time, the throughput must be measured from the server’s perspective....

February 13, 2018 · 5 min · 882 words · Benjamin Bengfort

Transaction Handling with Psycopg2

Databases are essential to most applications, however most database interaction is often overlooked by Python developers who use higher level libraries like Django or SQLAlchemy. We use and love PostgreSQL with Psycopg2, but I recently realized that I didn’t have a good grasp on how exactly psycopg2 implemented core database concepts: particularly transaction isolation and thread safety. Here’s what the documentation says regarding transactions: Transactions are handled by the connection class....

December 6, 2017 · 18 min · 3678 words · Benjamin Bengfort

Messaging Throughput gRPC vs. ZMQ

Building distributed systems in Go requires an RPC or message framework of some sort. In the systems I build I prefer to pass messages serialized with protocol buffers therefore a natural choice for me is grpc. The grpc library uses HTTP2 as a transport layer and provides a code generator based on the protocol buffer syntax making it very simple to use. For more detailed control, the ZMQ library is an excellent, low latency socket framework....

September 4, 2017 · 3 min · 429 words · Benjamin Bengfort