In the first Squirix previews, a cache read was a gRPC call to an ASP.NET Core application. Kestrel accepted the connection, and the SDK and server agreed on what a read looked like because they shared a .proto file. I could spend my time working out when a replica was allowed to acknowledge a write. The web stack earned its keep.
For 0.2.0-preview.1 I wanted to work on the cost of an ordinary cache hit. Say an application asks for a string that's already in memory. Looking up the key is only part of what it pays for. Someone still has to decode the request, encode the reply and decide when to send it. In this release I took those decisions into Squirix, and replaced the web host that used to run the node.
Four reads on one connection
The SDK was the first piece to move. Cache calls switched to a binary protocol over TLS while the server still used Kestrel and Protobuf. Say four small reads finish on the same connection. The server can write the ready replies into its output buffer and flush them together. When just one reply is ready, it can go straight out. A quiet connection pays no extra wait to fill a batch.
There was a second gRPC client inside the server. Nodes used it to talk to each other. Moving that traffic to a separate binary connection with mutual TLS removed the remaining server-side gRPC dependency. It also changed how you upgrade a cluster. All members have to switch together because the peer protocol changed.
What it took to remove Kestrel
Even with gRPC gone, Squirix still started as a web application. In this preview the node opens its own sockets and uses .NET's SslStream for TLS. The SDK connects to the cache listener. Cluster peers have their own listener, and health probes and Prometheus scrapers use HTTP/1.1 over TLS on a separate management address.
Removing the ASP.NET Core shared framework also meant picking up some less visible jobs. Squirix now starts and stops its own background workers, manages the lifetime of its services and handles logging inside the node. Its readiness monitor checks things like journal recovery and replica state. Bearer-token validation moved out of ASP.NET Core's JWT middleware. That work let the server drop the Generic Host, the Microsoft health-checks package and the OpenID Connect metadata package as runtime dependencies.
You can see the result in the Dockerfile. The final image runs on dotnet/runtime:10.0.15. If you embed the server, you can start it from a console application with SquirixServer.StartAsync. An ASP.NET Core application can still use Squirix through IDistributedCache. The integration package keeps the Microsoft abstractions that make this work.
Protobuf was a separate decision
At first, Squirix still used Protobuf to encode messages sent over the new connection. Later I removed the cache and replication .proto files, the gRPC build tools and the Google.Protobuf runtime. The SDK and server now share their own codec, so I can decide exactly which bytes a cache read sends back.
A small GetValueAsync reply starts with an eight-byte header. It contains the request ID, status and body length. On a cache miss the body length is zero, so the cache protocol sends just those eight bytes before TLS framing. If the server finds a small value, it writes the header and encodes the value right after it in the same output buffer. The writer needs no temporary byte array for that step.
What the measurements say
During the migration, three CI runs on Ubuntu with .NET 10 measured bytes allocated per operation when reading and writing short strings through the public SDK against a single node. The table shows the previous CI budget and the rounded average of those runs with persistence off.
| Operation | Previous CI budget | Measured during migration (B/op) |
|---|---|---|
| Read a value | 10,530 B/op | 3,217 B/op |
| Write a value | 11,780 B/op | 3,787 B/op |
The server was already using the new transport when CI ran these tests. It still used Protobuf. To see how long a read takes, I'd time one SDK call, then try several reads at once on the same connection.
That's the trade I've made in this preview. Early on, a generated client bought me time to work on replication. Today I can change how a cache miss is encoded or when a busy connection flushes, then measure that change through the same SDK an application uses. I also own the reader that has to cope when a client disconnects halfway through a frame.