HermitMQ: Architecture of a Go Message Broker with 3.4 GB/s Throughput and 2M+ Messages per Second

HermitMQ: Architecture of a Go Message Broker with 3.4 GB/s Throughput and 2M+ Messages per Second

HermitMQ is a high performance, open source message broker written in Go, purpose built for high load systems where standard solutions introduce excessive latency and garbage collector pressure. By replacing heavyweight serialization frameworks with a custom 29 byte binary protocol, an mmap indexed Write Ahead Log, and zero copy reads, the broker surpasses 2,000,000 messages per second (over 3.4 GB/s throughput) on an Apple M1 processor.

  1. Source Code & Documentation: GitHub ekhidirov/hermitmq
  2. Tech Stack: Go (Golang), Custom Binary TCP Protocol, Write Ahead Log, Memory Mapped Files (mmap), Zero Copy I/O, Built-in Client SDK.

Why Do Standard Brokers Become a Bottleneck?

In high load microservice architectures, traditional message brokers often hit three major bottlenecks: serialization/deserialization overhead (JSON/Protobuf), garbage collection pauses caused by constant heap allocations, and thread contention during concurrent writes to a single queue. The goal behind HermitMQ was to build an ultra fast, memory-predictable broker in pure Go with minimal response latency.

Key Architectural Decisions in HermitMQ

System ComponentHermitMQ ImplementationBusiness & Infrastructure Impact
Network ProtocolCustom 29 byte binary protocol over TCP without external serializersMinimal network overhead and zero redundant memory allocations when parsing headers
Data StorageTopic Partition model backed by a Write-Ahead Log with mmap indexed filesInstant offset lookups via memory mapped indexes and sequential disk writes
Network I/OZero Copy streaming via io.CopyNTransfers data directly from the file buffer to the socket bypassing user space, reaching read speeds up to 3.4 GB/s
Concurrency ControlLock Striping pattern (locks isolated by partition and segment)Eliminates contention on global mutexes when dozens of producers and consumers run simultaneously
Fault ToleranceBuilt-in Out Of Memory (OOM) protection and frame size validationStable operation under peak traffic without sudden node crashes caused by RAM exhaustion

Benchmarks

Testing was conducted on a local benchmark environment (Apple Silicon M1) using the project's built in Client SDK:

  1. Read Throughput (Zero Copy Read): Over 2,000,000 messages per second.
  2. Data Bandwidth: Over 3.4 GB/s.
  3. Memory Footprint: Flat RAM usage profile and minimal pressure on the Go Garbage Collector thanks to a zero allocation approach on the hot path.

Need High Load Backend Development or Go Bottleneck Optimization?

I apply the architectural principles behind HermitMQ—binary protocol design, zero-allocation data processing, custom queues, and network I/O optimization to commercial projects to reduce server infrastructure costs and accelerate system response times by orders of magnitude.

Architecture and development of high-load services in Go from scratch.

Profiling (pprof), memory leak resolution, and bottleneck optimization in existing backends.

Custom engineering of streaming services, message brokers, and network engines.