<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anshu Garg</title>
    <description>The latest articles on DEV Community by Anshu Garg (@anshugarg).</description>
    <link>https://dev.to/anshugarg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2600643%2F3f17081e-18ee-4d31-8847-edd87a9d10f3.png</url>
      <title>DEV Community: Anshu Garg</title>
      <link>https://dev.to/anshugarg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anshugarg"/>
    <language>en</language>
    <item>
      <title>Why I Built VortexMQ: A 167M ops/sec Message Broker in 100% Pure Go</title>
      <dc:creator>Anshu Garg</dc:creator>
      <pubDate>Sat, 19 Sep 2026 09:33:56 +0000</pubDate>
      <link>https://dev.to/anshugarg/why-i-built-vortexmq-a-167m-opssec-message-broker-in-100-pure-go-2577</link>
      <guid>https://dev.to/anshugarg/why-i-built-vortexmq-a-167m-opssec-message-broker-in-100-pure-go-2577</guid>
      <description>&lt;p&gt;Every engineering team eventually runs into the "message broker tax."&lt;/p&gt;

&lt;p&gt;You start building a clean, modern microservice architecture in Go or Rust. The services compile to small binaries, boot in 20 milliseconds, and use under 25 MB of memory. Everything feels snappy and predictable.&lt;/p&gt;

&lt;p&gt;Then your system grows, and you need asynchronous queueing, delayed job retries, and task streaming.&lt;/p&gt;

&lt;p&gt;So you deploy Kafka or RabbitMQ.&lt;/p&gt;

&lt;p&gt;Almost immediately, your infrastructure profile shifts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You now manage multi-gigabyte JVM heaps or an Erlang beam runtime.&lt;/li&gt;
&lt;li&gt;You need coordinator daemons (ZooKeeper, KRaft, or Mnesia clusters).&lt;/li&gt;
&lt;li&gt;Nodes consume 500 MB to 1 GB of RAM at idle before processing their first message.&lt;/li&gt;
&lt;li&gt;Stop-the-world garbage collection pauses occasionally turn a 150-microsecond latency into a 200-millisecond p99 spike.&lt;/li&gt;
&lt;li&gt;You have to wire up external Prometheus exporters, Grafana dashboards, and third-party UIs just to check queue depths and inspect dead messages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the queue consumes 20 times more resources than the application services producing and consuming the messages, something feels unbalanced.&lt;/p&gt;

&lt;p&gt;I wanted a message broker that felt like Go itself: a single 5.7 MB static binary, zero runtime dependencies, instant startup, sub-microsecond latency, and enough throughput to saturate a 10GbE network link on commodity hardware.&lt;/p&gt;

&lt;p&gt;That is why I built &lt;strong&gt;&lt;a href="https://github.com/GargAnshu9468/vortexmq" rel="noopener noreferrer"&gt;VortexMQ&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is VortexMQ?
&lt;/h2&gt;

&lt;p&gt;VortexMQ is an open-source, ultra-fast message broker and task engine written in pure Go (zero CGO, zero external dependencies).&lt;/p&gt;

&lt;p&gt;You can run it locally with Docker in a couple of seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8379:8379 &lt;span class="nt"&gt;-p&lt;/span&gt; 8380:8380 ianshugarg/vortexmq:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the core feature set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;167.1 Million ops/sec&lt;/strong&gt; lock-free ring buffer throughput (5.98 ns/op on bare metal)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2.33 Million ops/sec&lt;/strong&gt; full TCP network throughput with pooled memory buffers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drop-in Redis RESP2 and RESP3 compatibility&lt;/strong&gt;: connect using standard Redis clients in Go (&lt;code&gt;go-redis&lt;/code&gt;), Python (&lt;code&gt;redis-py&lt;/code&gt;), Node.js (&lt;code&gt;ioredis&lt;/code&gt;), Rust, or &lt;code&gt;redis-cli&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hierarchical Timing Wheel&lt;/strong&gt;: O(1) delayed message delivery without sorted set polling hacks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poison-Pill Dead Letter Queues (DLQ)&lt;/strong&gt;: automatic panic recovery that isolates crashing payloads with 1-click GUI replay&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embedded Quantum Web Studio&lt;/strong&gt;: an interactive dashboard served directly from the 5.7 MB binary on port 8380 via Go's &lt;code&gt;embed.FS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Under 15 MB RAM idle footprint&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Bottleneck in Go Channels (&lt;code&gt;chan T&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;When I started experimenting with the core engine, the first logical choice was native Go channels (&lt;code&gt;chan T&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Channels are great for application concurrency, but under heavy multi-core benchmark loads (32 producer goroutines pushing to 16 consumer workers), CPU profiles in &lt;code&gt;pprof&lt;/code&gt; revealed heavy lock contention. Internally, a Go channel uses an &lt;code&gt;hchan&lt;/code&gt; struct protected by a mutex (&lt;code&gt;hchan.lock&lt;/code&gt;). When dozens of cores hammer the same channel, CPU cores spend significant cycles waiting on cache-line invalidations and scheduler handoffs.&lt;/p&gt;

&lt;p&gt;Native channels hit a plateau around 12 to 15 million ops/sec with noticeable latency variance under contention.&lt;/p&gt;

&lt;p&gt;To get past this ceiling, I turned to the &lt;strong&gt;LMAX Disruptor pattern&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architectural Deep Dive: How We Reached 5.98 ns/op
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Producer goroutine
       │
       ▼
┌────────────────────────────────────────────────────────┐
│               LMAX DISRUPTOR RING BUFFER               │
│                                                        │
│  [Slot 0] [Slot 1] [Slot 2] [Slot 3] ... [Slot N]      │
│     ▲                                       ▲          │
│     │ atomic.AddUint64                      │          │
│  Head Seq                                Tail Seq      │
│  (64-byte padded)                  (64-byte padded)    │
└────────────────────────────────────────────────────────┘
       │
       ▼
Consumer goroutine (Sub-microsecond batching)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. Lock-Free Atomic Indexing
&lt;/h3&gt;

&lt;p&gt;Instead of holding mutexes, VortexMQ stores messages in a contiguous, power-of-two circular ring buffer.&lt;/p&gt;

&lt;p&gt;Publishers claim sequential slots using atomic instructions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;nextSeq&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;atomic&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddUint64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;slotIndex&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;nextSeq&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the buffer capacity is always a power of two (such as 65,536 or 1,048,576), calculating the slot index requires only a bitwise AND (&lt;code&gt;seq &amp;amp; mask&lt;/code&gt;). This replaces expensive CPU integer division with a single CPU clock cycle instruction.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Eliminating False Sharing with Cache-Line Padding
&lt;/h3&gt;

&lt;p&gt;Modern x86 and ARM processors do not read and write single bytes from RAM; they fetch memory in &lt;strong&gt;64-byte cache lines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If Core 0 (running a publisher) writes to the &lt;code&gt;head&lt;/code&gt; sequence counter, and Core 1 (running a consumer) reads the &lt;code&gt;tail&lt;/code&gt; sequence counter, but both variables share the same 64-byte memory segment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Core 0's write invalidates Core 1's L1/L2 cache line.&lt;/li&gt;
&lt;li&gt;Core 1 is forced to reload the entire line from L3 cache or main RAM, even though it never accessed &lt;code&gt;head&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This hardware contention (false sharing) can silently cut multi-core throughput by over 70%.&lt;/p&gt;

&lt;p&gt;In VortexMQ, every hot sequence counter is explicitly padded with 64-byte boundary arrays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;RingBuffer&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_pad0&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;
    &lt;span class="n"&gt;head&lt;/span&gt;  &lt;span class="kt"&gt;uint64&lt;/span&gt;
    &lt;span class="n"&gt;_pad1&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;
    &lt;span class="n"&gt;tail&lt;/span&gt;  &lt;span class="kt"&gt;uint64&lt;/span&gt;
    &lt;span class="n"&gt;_pad2&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;
    &lt;span class="n"&gt;mask&lt;/span&gt;  &lt;span class="kt"&gt;uint64&lt;/span&gt;
    &lt;span class="n"&gt;slots&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;MessageSlot&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This guarantees &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;tail&lt;/code&gt; never share a CPU cache line, allowing independent cores to run at full hardware memory bus speed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Zero Heap Allocations with &lt;code&gt;sync.Pool&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;In high-throughput Go services, garbage collector (GC) pauses are rarely caused by the number of objects; they are caused by the &lt;em&gt;rate of heap allocations&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If every incoming TCP frame allocates a new 4KB byte slice, processing 1 million messages per second allocates 4 GB of heap memory per second. The Go runtime will trigger continuous GC sweep phases, generating unpredictable latency spikes.&lt;/p&gt;

&lt;p&gt;VortexMQ uses tiered &lt;code&gt;sync.Pool&lt;/code&gt; arenas for RESP frame decoding and payload envelopment. Memory buffers are acquired from the pool on frame arrival and recycled immediately after the message is enqueued:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;framePool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pool&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;any&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On hot paths, heap allocations measure &lt;strong&gt;0 bytes per operation&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Drop-In Redis Compatibility: No Custom SDKs Required
&lt;/h2&gt;

&lt;p&gt;One of the biggest hurdles when adopting a new broker is having to install proprietary client SDKs and rewrite application code.&lt;/p&gt;

&lt;p&gt;VortexMQ implements the &lt;strong&gt;Redis Serialization Protocol (RESP2 and RESP3)&lt;/strong&gt; on port &lt;code&gt;8379&lt;/code&gt;. If your application already uses Redis for job queues or pub/sub, you can point your existing client directly to VortexMQ.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Python (&lt;code&gt;redis-py&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;

&lt;span class="c1"&gt;# Connect directly to VortexMQ on port 8379
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;localhost&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8379&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Publish a job
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lpush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tasks:orders&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;order_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: 9482, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;amount&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;: 149.99}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Consume with blocking pop
&lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;brpop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tasks:orders&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Processed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example: Go (&lt;code&gt;go-redis&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"context"&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/redis/go-redis/v9"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;rdb&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Options&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Addr&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"localhost:8379"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c"&gt;// Publish to the lock-free ring&lt;/span&gt;
    &lt;span class="n"&gt;rdb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LPush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"billing:invoices"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;`{"invoice_id": "INV-2026-001"}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Blocking consumer worker&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;rdb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BRPop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"billing:invoices"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Received payload: %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  O(1) Delayed Scheduling: Hierarchical Timing Wheel
&lt;/h2&gt;

&lt;p&gt;Scheduling messages for future execution (such as retry delays, billing reminders, or notification timers) is usually awkward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In RabbitMQ, teams often combine dead-letter exchanges with TTLs or install plugins.&lt;/li&gt;
&lt;li&gt;In Redis, workers poll sorted sets (&lt;code&gt;ZADD&lt;/code&gt; and &lt;code&gt;ZRANGEBYSCORE&lt;/code&gt;), which creates CPU burn and race conditions across multiple consumers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;VortexMQ embeds a &lt;strong&gt;Hierarchical Timing Wheel&lt;/strong&gt; (inspired by the Linux kernel timer model):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Wheel 0: 10ms per tick]  ──► Range: 0 to 1,000ms
       │
[Wheel 1: 1s per tick]   ──► Range: 1s to 60s
       │
[Wheel 2: 1m per tick]   ──► Range: 1m to 60m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inserting or canceling a timer is strictly an &lt;strong&gt;O(1)&lt;/strong&gt; pointer operation. Messages sleep efficiently without thread-blocking until their exact deadline, at which point the timer drops the message directly into the consumer's active ring buffer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Production Guardrails: Poison-Pill Quarantine &amp;amp; Web UI
&lt;/h2&gt;

&lt;p&gt;A common failure mode in background worker pools is the "poison pill" payload: a malformed JSON string or unexpected schema that triggers an unhandled panic in the consumer. Standard queues will often re-queue the payload indefinitely, trapping workers in a crash loop.&lt;/p&gt;

&lt;p&gt;VortexMQ includes built-in panic guards:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When a worker crashes or exceeds its retry budget (&lt;code&gt;MaxRetries = 3&lt;/code&gt;), the broker isolates the message.&lt;/li&gt;
&lt;li&gt;The payload is moved to the topic's &lt;strong&gt;Dead Letter Queue (DLQ)&lt;/strong&gt; along with the failure timestamp, error reason, and stack trace.&lt;/li&gt;
&lt;li&gt;The rest of the queue continues processing uninterrupted.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From the embedded &lt;strong&gt;Quantum Web Studio&lt;/strong&gt; (&lt;code&gt;http://localhost:8380&lt;/code&gt;), you can inspect the quarantined payloads, check consumer lag, and click &lt;strong&gt;Replay&lt;/strong&gt; to re-inject fixed messages into active processing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Benchmark Numbers (Reproducible)
&lt;/h2&gt;

&lt;p&gt;All benchmarks can be verified locally on bare metal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/GargAnshu9468/vortexmq.git
&lt;span class="nb"&gt;cd &lt;/span&gt;vortexmq
go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-benchmem&lt;/span&gt; &lt;span class="nt"&gt;-bench&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; ./benchmarks/...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Benchmark Results
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Throughput&lt;/th&gt;
&lt;th&gt;Latency&lt;/th&gt;
&lt;th&gt;Heap Allocation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ring Buffer Push/Pop&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;167.1M ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.98 ns/op&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0 B/op (0 allocs)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TCP Client (Pipelined)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.33M ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;428 ns/op&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0 B/op pooled&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hierarchical Timer Wheel&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;14.2M ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70.1 ns/op&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0 B/op&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DLQ Panic Quarantine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.85M ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;540 ns/op&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1 alloc/op&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What VortexMQ is NOT (Engineering Trade-offs)
&lt;/h2&gt;

&lt;p&gt;No tool is right for every problem. Being clear about trade-offs is essential:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not an analytical data lake&lt;/strong&gt;: If you need multi-month event retention across hundreds of gigabytes for Hadoop or Snowflake queries with tiered S3 storage, Kafka is the right tool. VortexMQ is designed for high-velocity operational messaging and task dispatching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not a complex AMQP topology&lt;/strong&gt;: If you require intricate topic exchanges, header routing rules, and dynamic queue federations with dozens of AMQP plugins, RabbitMQ's feature set is broader. VortexMQ prioritizes raw speed, simplicity, and standard Redis protocol semantics.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;You can test VortexMQ in less than a minute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Start with Docker&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; vortexmq &lt;span class="nt"&gt;-p&lt;/span&gt; 8379:8379 &lt;span class="nt"&gt;-p&lt;/span&gt; 8380:8380 ianshugarg/vortexmq:latest

&lt;span class="c"&gt;# 2. Test with redis-cli&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-p&lt;/span&gt; 8379 LPUSH my-queue &lt;span class="s2"&gt;"Hello VortexMQ"&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-p&lt;/span&gt; 8379 BRPOP my-queue 0

&lt;span class="c"&gt;# 3. Open Web Studio in your browser&lt;/span&gt;
open http://localhost:8380
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/GargAnshu9468/vortexmq" rel="noopener noreferrer"&gt;github.com/GargAnshu9468/vortexmq&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Documentation &amp;amp; Live Simulator&lt;/strong&gt;: &lt;a href="https://garganshu9468.github.io/vortexmq/" rel="noopener noreferrer"&gt;garganshu9468.github.io/vortexmq&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical Wiki&lt;/strong&gt;: &lt;a href="https://github.com/GargAnshu9468/vortexmq/wiki" rel="noopener noreferrer"&gt;github.com/GargAnshu9468/vortexmq/wiki&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Discussions&lt;/strong&gt;: &lt;a href="https://github.com/GargAnshu9468/vortexmq/discussions" rel="noopener noreferrer"&gt;github.com/GargAnshu9468/vortexmq/discussions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback, PRs, and benchmark reports on different hardware architectures are very welcome!&lt;/p&gt;

</description>
      <category>go</category>
      <category>performance</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How We Built the Fastest In-Memory Key-Value Store in Pure Go (Hitting 6.87M ops/sec Without CGO)</title>
      <dc:creator>Anshu Garg</dc:creator>
      <pubDate>Fri, 18 Sep 2026 16:46:16 +0000</pubDate>
      <link>https://dev.to/anshugarg/how-we-built-the-fastest-in-memory-key-value-store-in-pure-go-hitting-687m-opssec-without-cgo-39ae</link>
      <guid>https://dev.to/anshugarg/how-we-built-the-fastest-in-memory-key-value-store-in-pure-go-hitting-687m-opssec-without-cgo-39ae</guid>
      <description>&lt;p&gt;For over a decade, the consensus in systems engineering has been unanimous: &lt;strong&gt;if you want raw, bare-metal networking throughput, you write it in C, C++, or Rust.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Managed runtimes with garbage collection—especially Go—were considered "great for microservices and cloud infrastructure," but fundamentally handicapped for extreme low-latency, multi-million-ops-per-second storage engines.&lt;/p&gt;

&lt;p&gt;Standard Redis processes commands through a single-threaded event loop. While simple and lock-free, single-threaded architectures leave 95% of modern multi-core server CPUs completely idle.&lt;/p&gt;

&lt;p&gt;When we set out to build &lt;a href="https://github.com/GargAnshu9468/vortexkv" rel="noopener noreferrer"&gt;&lt;strong&gt;VortexKV&lt;/strong&gt;&lt;/a&gt;, our goal was ambitious:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Can we build a drop-in Redis replacement in 100% pure Go (zero CGO, zero external C dependencies) that not only matches Redis, but shatters its concurrent throughput—hitting over 6.8 Million ops/sec while keeping p50 latency under 120 microseconds?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the exact architecture, the bottlenecks we hit, and the engineering breakthroughs that made it possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Benchmark Numbers
&lt;/h2&gt;

&lt;p&gt;Before diving into code, here are the audited benchmark numbers running on modern hardware (verified via standard &lt;code&gt;redis-benchmark&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workload Configuration&lt;/th&gt;
&lt;th&gt;Operations / Sec&lt;/th&gt;
&lt;th&gt;p50 Latency&lt;/th&gt;
&lt;th&gt;Bottleneck&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Direct Concurrency (Non-pipelined, C=50)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;206,611 ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;119 µs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Network RTT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Medium Pipeline (P=16, C=50)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1,984,127 ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;271 µs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Socket buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Peak Pipelined GET (P=64, C=50)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2,631,579 ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.07 ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CPU memory bus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Peak Pipelined PING (P=64, C=100)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9,259,259 ops/sec&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;175 µs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hardware theoretical max&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Anyone can verify these numbers on their own machine in 60 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/GargAnshu9468/vortexkv.git
&lt;span class="nb"&gt;cd &lt;/span&gt;vortexkv
./scripts/reproduce_benchmarks.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why Standard Go (&lt;code&gt;net.Listen&lt;/code&gt;) Fails at 1M+ ops/sec
&lt;/h2&gt;

&lt;p&gt;The idiomatic way to write network servers in Go is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"tcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;":7379"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ln&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="n"&gt;handleConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Goroutine-per-connection&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This model is elegant for web servers. But at &lt;strong&gt;500,000+ commands per second&lt;/strong&gt;, it hits a performance cliff:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Goroutine Stack Overhead&lt;/strong&gt;: Even a 2KB stack per goroutine causes cache line pollution across L1/L2 CPU caches when thousands of connections churn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Go Runtime Scheduler Preemption&lt;/strong&gt;: Cooperative scheduling introduces micro-jitter and context-switching overhead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write Syscall Amplification&lt;/strong&gt;: Writing each small Redis response (e.g. &lt;code&gt;+OK\r\n&lt;/code&gt; or &lt;code&gt;+PONG\r\n&lt;/code&gt;) incurs an independent kernel write syscall. Syscalls are expensive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To hit 6.8M+ ops/sec, we had to rethink the networking engine from the metal up.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Pinned Multi-Reactor with &lt;code&gt;runtime.LockOSThread()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Rather than spawning unbounded goroutines, VortexKV implements a hardware-accelerated &lt;strong&gt;Multi-Reactor pattern&lt;/strong&gt; (using Linux &lt;code&gt;epoll&lt;/code&gt; and macOS/BSD &lt;code&gt;kqueue&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;A central acceptor reactor handles incoming client connections and distributes them across a fixed pool of worker reactors (one worker per available CPU core):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ReactorWorker&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Pin this goroutine to a dedicated OS thread&lt;/span&gt;
    &lt;span class="n"&gt;runtime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LockOSThread&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;runtime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UnlockOSThread&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="n"&gt;KEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stopped&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;poll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handleEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why &lt;code&gt;runtime.LockOSThread()&lt;/code&gt; matters:
&lt;/h3&gt;

&lt;p&gt;By binding the event reactor worker permanently to an OS thread, the OS scheduler never migrates the loop between CPU cores. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;L1/L2 Instruction &amp;amp; Data Cache Preservation&lt;/strong&gt;: CPU caches stay hot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero Cache Line Bouncing&lt;/strong&gt;: Kernel socket notifications land on the exact core that owns the connection.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Zero-Allocation Cyclic Ring Buffers
&lt;/h2&gt;

&lt;p&gt;Under extreme network load, Go's Garbage Collector (GC) is your biggest enemy. If every socket read allocates a new &lt;code&gt;make([]byte, 4096)&lt;/code&gt;, GC pauses quickly degrade p99 latency into milliseconds.&lt;/p&gt;

&lt;p&gt;VortexKV equips every active client connection with a dedicated &lt;strong&gt;cyclic circular ring buffer&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;ConnectionRing&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;buf&lt;/span&gt;    &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;
    &lt;span class="n"&gt;head&lt;/span&gt;   &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;tail&lt;/span&gt;   &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;mask&lt;/span&gt;   &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ConnectionRing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;ReadFromSocket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Read directly into preallocated ring buffer without heap allocs&lt;/span&gt;
    &lt;span class="c"&gt;// Wrap-around handled via bitwise mask: (pos &amp;amp; mask)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because socket payloads are processed, decoded, and executed in-place within the ring buffer, &lt;strong&gt;the steady-state read pipeline produces zero heap allocations.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Batch Socket Write Coalescing
&lt;/h2&gt;

&lt;p&gt;In Redis pipelines, a client sends 64 or 128 commands back-to-back in a single TCP packet.&lt;/p&gt;

&lt;p&gt;If a server responds by issuing 64 individual &lt;code&gt;write()&lt;/code&gt; syscalls back to the socket, the Linux kernel spends more time switching between user space and kernel space than actually moving data.&lt;/p&gt;

&lt;p&gt;VortexKV implements &lt;strong&gt;smart socket write coalescing&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;QueueResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writeBuf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// If the socket receive queue still has pending commands,&lt;/span&gt;
    &lt;span class="c"&gt;// coalesce responses in memory instead of flushing immediately&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hasPendingReads&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writeBuf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Len&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;MaxBatchSize&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c"&gt;// Flush all queued responses in a single vectorized kernel write&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When processing pipelined workloads, &lt;strong&gt;up to 128 responses are consolidated into a single kernel &lt;code&gt;writev&lt;/code&gt; / &lt;code&gt;send&lt;/code&gt; syscall&lt;/strong&gt;. This single optimization boosted pipelined throughput from 1.8M ops/sec to over &lt;strong&gt;6.87M ops/sec&lt;/strong&gt;!&lt;/p&gt;




&lt;h2&gt;
  
  
  4. 64 Mutex-Striped Shards with Cacheline Padding
&lt;/h2&gt;

&lt;p&gt;Standard Redis is single-threaded to avoid lock contention. But to utilize all 16 or 32 cores on modern hardware, you need concurrency.&lt;/p&gt;

&lt;p&gt;If you protect your keyspace with a global &lt;code&gt;sync.RWMutex&lt;/code&gt;, CPU cores fight over the same memory cache line, causing devastating lock convoying.&lt;/p&gt;

&lt;p&gt;VortexKV splits the global keyspace into &lt;strong&gt;64 independent, lock-striped shards&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;KeyspaceShard&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;mu&lt;/span&gt;    &lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RWMutex&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;  &lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;vortexObject&lt;/span&gt;
    &lt;span class="c"&gt;// Cacheline padding: prevents CPU False Sharing&lt;/span&gt;
    &lt;span class="n"&gt;_pad&lt;/span&gt;  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Engine&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;shards&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;KeyspaceShard&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Secret: Cacheline Padding (&lt;code&gt;_pad [64]byte&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Modern x86 and ARM CPUs synchronize memory in 64-byte chunks (cache lines). If two mutexes reside in the same 64-byte cache line, Core 0 updating Shard 0 invalidates the cache line for Core 1 updating Shard 1—even though they are locking completely different data!&lt;/p&gt;

&lt;p&gt;By padding each shard with &lt;code&gt;[64]byte&lt;/code&gt;, every mutex occupies its own dedicated cache line. Contention drops to near-zero.&lt;/p&gt;




&lt;h2&gt;
  
  
  More Than Just a Cache: AI Vectors &amp;amp; Streams
&lt;/h2&gt;

&lt;p&gt;Because we built the storage engine in pure Go, we could embed modern capabilities that traditional Redis lacks:&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Native HNSW AI Vector Search
&lt;/h3&gt;

&lt;p&gt;Skip external vector databases. Store high-dimensional embeddings and execute nearest-neighbor queries directly in VortexKV:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Store vector embeddings&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-p&lt;/span&gt; 7379 VADD embeddings doc1 0.95 0.05 0.0 0.0

&lt;span class="c"&gt;# Top-1 Cosine Similarity search&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-p&lt;/span&gt; 7379 VSEARCH embeddings 1 cosine 0.90 0.10 0.0 0.0
&lt;span class="c"&gt;# Returns: "doc1", "0.999512"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🌊 Event Streams with Consumer Groups &amp;amp; PEL
&lt;/h3&gt;

&lt;p&gt;Full support for distributed event streaming with &lt;code&gt;XADD&lt;/code&gt;, &lt;code&gt;XREADGROUP&lt;/code&gt;, &lt;code&gt;XACK&lt;/code&gt;, and Pending Entries Lists.&lt;/p&gt;

&lt;h3&gt;
  
  
  🌌 Embedded Cyberpunk Web Studio (:7380)
&lt;/h3&gt;

&lt;p&gt;The binary embeds a visual web command deck with 2D/3D keyspace visualization, live latency monitors, slowlog stream, and ACL configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  Running VortexKV in 30 Seconds
&lt;/h2&gt;

&lt;p&gt;VortexKV is completely open-source under the MIT license.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Via One-Line Installer (macOS / Linux):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/GargAnshu9468/vortexkv/main/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Via Docker:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 7379:7379 &lt;span class="nt"&gt;-p&lt;/span&gt; 7380:7380 ianshugarg/vortexkv:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Connect with your favorite Redis client:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;redis-cli &lt;span class="nt"&gt;-p&lt;/span&gt; 7379 PING
&lt;span class="c"&gt;# PONG&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion &amp;amp; Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Building high-throughput network engines in Go isn't about avoiding the language—it's about understanding the runtime:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pin workers with &lt;code&gt;LockOSThread()&lt;/code&gt;&lt;/strong&gt; to avoid CPU core thrashing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use preallocated ring buffers&lt;/strong&gt; to starve the garbage collector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch kernel write syscalls&lt;/strong&gt; when queues drain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pad concurrent structs with 64 bytes&lt;/strong&gt; to stop cache line bouncing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you love systems engineering, performance optimization, and pure Go, check out the code and consider leaving a star!&lt;/p&gt;

&lt;p&gt;⭐ &lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/GargAnshu9468/vortexkv" rel="noopener noreferrer"&gt;https://github.com/GargAnshu9468/vortexkv&lt;/a&gt;&lt;br&gt;&lt;br&gt;
🌐 &lt;strong&gt;Live Interactive Web Demo&lt;/strong&gt;: &lt;a href="https://garganshu9468.github.io/vortexkv/" rel="noopener noreferrer"&gt;https://garganshu9468.github.io/vortexkv/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
📖 &lt;strong&gt;Official Wiki &amp;amp; Docs&lt;/strong&gt;: &lt;a href="https://github.com/GargAnshu9468/vortexkv/wiki" rel="noopener noreferrer"&gt;https://github.com/GargAnshu9468/vortexkv/wiki&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>database</category>
      <category>performance</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
