Blogs

Why we built Nasiko in Rust

Kuldeep Singh, Tech Lead

Illustration: a hand placing a cube with the Nasiko mark on top of a stack of dark cubes, the largest marked with the Rust logo.

Nasiko is written in Rust. Not one service, not the hot path with a friendlier language around it. The whole platform.

People ask why, usually with some version of “wasn’t that harder?” It was, in places. This post explains why we did it anyway, what it cost us, and how the same thinking shaped the rest of our stack.

What a runtime in the path demands

Nasiko sits in the path of agent work. Every call to an agent goes through our proxy. Every model call goes through our gateway. Every tool call goes through our tool gateway. That position is the product, and it’s also the constraint that drove every technology choice we made.

If you sit in the path, five things have to be true:

  • Your overhead has to be small and predictable. An agent run can involve hundreds of model and tool calls. Whatever latency we add, we add it hundreds of times. The average matters less than the tail, because one slow hop stalls the whole run.
  • You have to hold a lot of connections open. Agent traffic is streaming traffic. Responses arrive as events over long-lived connections, and a busy deployment holds thousands of them at once.
  • You can never be the reason work stops. If we crash, every agent behind us stops. A runtime has to be more reliable than the things it runs.
  • You have to run anywhere. Our customers run Nasiko on a laptop, in their cloud, and in private clusters. We can’t assume a particular platform underneath us.
  • You have to be cheap to run. A platform that helps companies control agent spend shouldn’t arrive with a large infrastructure bill of its own.
Five requirements of a runtime in the path: 01 Predictable overhead, 02 Thousands of connections, 03 Never the reason work stops, 04 Runs anywhere, 05 Cheap to run, each with an icon and a one-line explanation.

Rust is the language where all five were achievable at the same time.

Why Rust

No garbage collector in the request path

Most languages we could have chosen manage memory with a garbage collector. That works well for a lot of software, but collectors pause, and pauses show up as latency spikes at exactly the wrong moments, under load. Rust has no collector. Memory is freed deterministically when it goes out of scope, so our overhead per call stays flat as traffic grows. For a proxy that sits in front of every model call, flat is the property we care about most.

Cheap concurrency for streaming workloads

An agent conversation is a long-lived stream, and each one mostly waits: on a model, on a tool, on another agent. Rust’s async model fits that shape well. Each connection is a lightweight task rather than an operating system thread, so one server can hold many open streams with a small memory footprint.

Just as important, the compiler checks our concurrency. Data races, the class of bug that only appears under production load at 3 a.m., are compile errors in Rust. When your server is shared by every agent in a company, that guarantee is worth a great deal.

Failure handling you can’t forget

Nasiko makes deliberate choices about failure. Agent selection and model routing fail open, so work keeps moving. Flow limits fail closed, so a runaway loop stops. Those choices only hold if every failure path is handled on purpose.

Rust makes that the default. There are no unchecked exceptions. A function that can fail returns a result, and the compiler won’t let you ignore it. Every place we fail open or fail closed is visible in the code as a decision someone made, not an accident of what happened to get caught. We also isolate background work, so if a build task panics, it takes down that task and nothing else.

Traits as seams

Rust’s traits let us define an interface once and swap what sits behind it. Our container runtime is a trait, with one implementation for a single Docker host and another for Kubernetes. Observability, routing and authentication work the same way. The core of the platform never asks which environment it’s in. It calls the interface, and the right implementation is chosen once, where the server is assembled. That keeps conditionals out of the business logic and makes new environments an addition rather than a rewrite.

Efficiency is part of the product

Rust uses less CPU and memory for the same work than most alternatives. For us, that isn’t only an operations benefit. A runtime that prices every model call and enforces budgets has to do that work on every request, and doing it cheaply is what lets us do it everywhere without a sampling shortcut.

A strong ecosystem for data

Much of the modern data stack is being built in Rust, including the columnar and table formats we use for our data lakehouse. Building the platform in the same language means we call those libraries directly, with no serialization boundary between the server and its data layer.

What Rust cost us

None of this was free, and a post like this isn’t useful if it pretends otherwise.

  • Compile times. A large Rust codebase takes real time to build. We’ve had to invest in how we structure the workspace and our build pipeline to keep the feedback loop tolerable.
  • A smaller hiring pool. There are fewer experienced Rust engineers than Python or Go engineers. We’ve found that strong engineers pick it up, but it takes deliberate onboarding.
  • The AI ecosystem lives in Python. Most agent frameworks and model tooling are Python-first. We decided early that this was fine, because the runtime and the agents it runs are different things. Nasiko is Rust. The agents can be written in whatever their authors prefer, and most are Python. Our job is to meet them at the protocol, not to dictate their language.

One thing made the trade easier than we expected. We use coding agents heavily ourselves, and Rust’s strict compiler turns out to be an excellent reviewer of machine-written code. A wrong assumption that would slip through in a looser language gets stopped at compile time.

The rest of the stack

The language is one decision. The same three rules guided everything around it: prefer open standards, keep the number of moving parts small, and choose tools our customers can run themselves.

Postgres for durable state, and for queues

Postgres holds everything that must not be lost: identity and org structure, agents and versions, conversations and flows, the usage ledger and pricing.

It’s also our job queue. Build workers claim jobs with row-level locks that skip rows another worker already holds, which gives us a safe multi-worker queue with no extra system to operate. Because the queue lives in the same database as the data, registering an agent, recording its build, and enqueuing the job happen in one transaction. Either all of it happened, or none of it did.

Redis for coordination that can be lost

Redis holds state that is fast-moving and safe to rebuild: flow-limit counters keyed by trace, the maps that tie traces to sessions, and short-lived caches. Multi-agent flows run on Redis streams with consumer groups, so several workers share the load and a run that stalls on one worker is reclaimed by another.

The rule is simple. If losing it would lose a customer’s data, it goes in Postgres. If losing it only costs a retry, it can go in Redis.

Object storage for everything large

Image layers, build contexts, and older usage data live in S3-compatible object storage. Layers are stored by content digest, so identical layers across agents are stored once. For self-hosted deployments, we use an S3-compatible store, so the platform behaves the same in a customer’s cluster as it does in ours.

OpenTelemetry, Tempo and Loki for observability

We instrument with OpenTelemetry because it’s the open standard, and its conventions for generative AI give model calls a shared vocabulary: which model, how many tokens in, how many out. Trace context propagates across every hop, which is what lets a multi-agent interaction read as one trace.

For storing those traces, we chose Tempo. Agent workloads produce a very large number of spans, and most are never looked at. Tempo is built for that profile. It writes traces to object storage rather than maintaining a heavy index, so storing everything is affordable, and its query language lets us find spans by attributes like session, agent, and model when we need them. That combination is what lets us keep full traces instead of sampling them away.

Logs go to Loki for the same reasons. It indexes labels rather than full text, stores log data in object storage, and shares an operational model with Tempo. A trace ID in a log line takes you from a log to the exact trace it belongs to.

A failed Nasiko session, $1.78 across four traces, open on its third trace: a waterfall of 29 spans for one coding-agent turn, with model calls, Bash commands and MCP tool calls on a timeline, and one failed span’s status, duration, tokens, cost and model in a side panel.

Kubernetes, with autoscaling driven by events

In production, agents run on Kubernetes, with event-driven autoscaling that scales on concurrency and can scale an idle agent to zero. For a single machine, the same runtime interface drives Docker directly.

Builds run inside the cluster with BuildKit, so we don’t need a privileged Docker daemon on our nodes. Built images go to an OCI registry embedded in the Nasiko server. Using the standard registry protocol means any standard tool can push to it, and there’s no external registry to provision before the platform works.

Sandboxes for on-demand workloads

On-demand agent containers run in sandboxes that give each workload its own isolated kernel surface. We use gVisor today because it starts quickly and runs on standard nodes. We’re working toward Firecracker with snapshot and restore, so a parked workload can wake almost exactly where it left off.

A lakehouse for data that never stops growing

Recent usage data stays in Postgres, where it’s fast to query and update. Older data tiers to object storage in columnar formats, and queries read across both tiers with one cursor. We use Lance for vector, memory and cold analytical data.

Open protocols at every boundary

Agents talk to each other over A2A. Tools are reached over MCP. Coding agents connect through the Agent Client Protocol. We chose open protocols at every boundary for the same reason we chose open tools: a runtime that works across vendors can’t be built on a proprietary interface.

The stack at a glance

ChoiceWhat it does for NasikoWhy we chose it
RustThe entire platformPredictable latency, safe concurrency, explicit failure handling, and a single binary
PostgresDurable state and job queuesOne transactional system instead of a database plus a queue
RedisFlow limits, flow streams, cachesFast coordination for state that is safe to rebuild
Object storageImage layers, build contexts, cold dataCheap, content-addressed and available everywhere
OpenTelemetryInstrumentation and trace contextThe open standard, with shared conventions for model calls
TempoTrace storageAffordable storage for every span, queryable by attribute
LokiLog storageLabel-indexed logs on object storage, linked to traces
Kubernetes and event-driven autoscalingRunning and scaling agentsScale on concurrency, down to zero
BuildKit and an embedded OCI registryBuilding and storing agent imagesIn-cluster builds and no external registry to manage
LanceVector, memory and cold analytical dataColumnar formats with native Rust support
A2A, MCP and ACPAgent, tool and harness communicationOpen protocols that work across vendors

What we’d tell another team

If you’re deciding whether Rust is right for your own infrastructure, here is what we’d pass on.

  • Choose it for where the code sits, not for fashion. Rust earned its place here because we sit in the request path. For a back-office tool that runs once a day, we’d have chosen differently.
  • Let the type system carry your design decisions. Our fail-open and fail-closed rules hold because the compiler enforces them. Put your most important guarantees where they can’t be forgotten.
  • Keep the stack small. Using Postgres as a queue and object storage as the backing for traces, logs, and cold data means fewer systems to run, in our cloud and in our customers’.
  • Meet the ecosystem at the protocol. We didn’t need agents to be written in Rust. We needed a fast, reliable layer that speaks open protocols to agents written in anything.

The result is a runtime we can put in front of every agent call, every model call, and every tool call without becoming the bottleneck or the weak point. That was the goal, and the stack is how we got there.

Create an account