# netflix/rend architecture

> Architecture diagram of the GitHub repository netflix/rend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/netflix/rend
- Repository: https://github.com/netflix/rend

## Overview

Rend is a Memcached-compatible server and cache proxy. A client connects to the listener; text or binary requests are parsed, coordinated in L1-only or L1/L2 mode, dispatched to a selected storage handler, and answered using the corresponding protocol. Storage options include in-memory, ordinary Memcached, batched, and fixed-chunk Memcached handlers. The repository also includes load and correctness clients, plus shared metrics and timing support. The main workflow and documented capabilities are represented; some handler internals and wiring are unsampled, so uncertain links are omitted.

Main entry points: [`memproxy.go`](https://github.com/netflix/rend/blob/master/memproxy.go) (Server configuration), [`handlers/memcached/std/handler.go`](https://github.com/netflix/rend/blob/master/handlers/memcached/std/handler.go) (Memcached handler), [`server/listen.go`](https://github.com/netflix/rend/blob/master/server/listen.go) (Connection listener), [`client/cmd/blast/main.go`](https://github.com/netflix/rend/blob/master/client/cmd/blast/main.go) (Load and correctness clients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_memproxy["Server configuration<br/>[memproxy.go]"]
  node_listener["Connection listener<br/>[listen.go]"]
  node_default["Default server<br/>[default.go]"]
end

subgraph group_protocol["Protocol handling"]
  node_text_parser["Text parser<br/>[parser.go]"]
  node_binary_parser["Binary parser<br/>[parser.go]"]
  node_text_response["Text responses<br/>[respond.go]"]
  node_binary_response["Binary responses<br/>[respond.go]"]
end

subgraph group_orchestration["Request orchestration"]
  node_l1only["L1-only logic<br/>[l1only.go]"]
  node_l1l2["L1/L2 logic<br/>[l1l2.go]"]
  node_l1l2batch["Batch L1/L2 logic<br/>[l1l2batch.go]"]
end

subgraph group_storage["Storage handlers"]
  node_inmem[("In-memory handler<br/>[inmem.go]")]
  node_std_handler["Memcached handler<br/>[handler.go]"]
  node_batched_handler["Batched handler<br/>[handler.go]"]
  node_batched_conn["Batch connections<br/>[conn.go]"]
  node_chunked_handler["Chunked handler<br/>[handler.go]"]
end

subgraph group_client["Client tools"]
  node_client_tools["Load and correctness clients<br/>[main.go]"]
  node_client_binary["Binary client protocol<br/>[prot.go]"]
  node_client_text["Text client protocol<br/>[prot.go]"]
end

subgraph group_shared["Shared instrumentation"]
  node_metrics["Metrics library<br/>[endpoint.go]"]
  node_timer["Timing utility<br/>[timer.go]"]
end

node_client_actor(("Memcached client"))
node_external_memcached[("Memcached backend")]

node_client_actor -->|"connects to"| node_listener
node_memproxy -->|"configures"| node_listener
node_memproxy -->|"selects"| node_l1only
node_memproxy -->|"selects"| node_l1l2
node_memproxy -->|"selects"| node_std_handler
node_memproxy -->|"selects"| node_batched_handler
node_memproxy -->|"selects"| node_chunked_handler
node_memproxy -->|"selects"| node_inmem
node_listener -->|"uses"| node_default
node_listener -.->|"routes requests"| node_text_parser
node_listener -.->|"routes requests"| node_binary_parser
node_default -->|"dispatches"| node_l1only
node_default -->|"dispatches"| node_l1l2
node_text_parser -.->|"formats replies"| node_text_response
node_binary_parser -.->|"formats replies"| node_binary_response
node_l1only -->|"dispatches"| node_inmem
node_l1only -.->|"dispatches"| node_std_handler
node_l1l2 -.->|"dispatches"| node_std_handler
node_l1l2batch -.->|"dispatches"| node_std_handler
node_l1l2batch -.->|"dispatches"| node_batched_handler
node_batched_handler -->|"uses"| node_batched_conn
node_std_handler -->|"sends commands"| node_external_memcached
node_batched_conn -->|"sends batches"| node_external_memcached
node_chunked_handler -->|"stores chunks"| node_external_memcached
node_client_tools -->|"uses"| node_client_binary
node_client_tools -->|"uses"| node_client_text
node_client_tools -.->|"sends requests"| node_client_actor
node_client_tools -->|"measures duration"| node_timer
node_l1l2 -->|"records"| node_metrics
node_std_handler -->|"records"| node_metrics
node_binary_parser -->|"records"| node_metrics
node_text_parser -->|"timestamps requests"| node_timer

click node_memproxy "https://github.com/netflix/rend/blob/master/memproxy.go"
click node_listener "https://github.com/netflix/rend/blob/master/server/listen.go"
click node_default "https://github.com/netflix/rend/blob/master/server/default.go"
click node_text_parser "https://github.com/netflix/rend/blob/master/protocol/textprot/parser.go"
click node_binary_parser "https://github.com/netflix/rend/blob/master/protocol/binprot/parser.go"
click node_text_response "https://github.com/netflix/rend/blob/master/protocol/textprot/respond.go"
click node_binary_response "https://github.com/netflix/rend/blob/master/protocol/binprot/respond.go"
click node_l1only "https://github.com/netflix/rend/blob/master/orcas/l1only.go"
click node_l1l2 "https://github.com/netflix/rend/blob/master/orcas/l1l2.go"
click node_l1l2batch "https://github.com/netflix/rend/blob/master/orcas/l1l2batch.go"
click node_inmem "https://github.com/netflix/rend/blob/master/handlers/inmem/inmem.go"
click node_std_handler "https://github.com/netflix/rend/blob/master/handlers/memcached/std/handler.go"
click node_batched_handler "https://github.com/netflix/rend/blob/master/handlers/memcached/batched/handler.go"
click node_batched_conn "https://github.com/netflix/rend/blob/master/handlers/memcached/batched/conn.go"
click node_chunked_handler "https://github.com/netflix/rend/blob/master/handlers/memcached/chunked/handler.go"
click node_client_tools "https://github.com/netflix/rend/blob/master/client/cmd/blast/main.go"
click node_client_binary "https://github.com/netflix/rend/blob/master/client/binprot/prot.go"
click node_client_text "https://github.com/netflix/rend/blob/master/client/textprot/prot.go"
click node_metrics "https://github.com/netflix/rend/blob/master/metrics/endpoint.go"
click node_timer "https://github.com/netflix/rend/blob/master/timer/timer.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_memproxy,node_listener,node_default toneBlue
class node_text_parser,node_binary_parser,node_text_response,node_binary_response,node_client_actor,node_external_memcached toneAmber
class node_l1only,node_l1l2,node_l1l2batch toneMint
class node_inmem,node_std_handler,node_batched_handler,node_batched_conn,node_chunked_handler toneRose
class node_client_tools,node_client_binary,node_client_text toneIndigo
class node_metrics,node_timer toneTeal
```

## Components

### Server runtime

- [Server configuration](https://github.com/netflix/rend/blob/master/memproxy.go): `memproxy.go`
- [Connection listener](https://github.com/netflix/rend/blob/master/server/listen.go): `server/listen.go`
- [Default server](https://github.com/netflix/rend/blob/master/server/default.go): `server/default.go`

### Protocol handling

- [Text parser](https://github.com/netflix/rend/blob/master/protocol/textprot/parser.go): `protocol/textprot/parser.go`
- [Binary parser](https://github.com/netflix/rend/blob/master/protocol/binprot/parser.go): `protocol/binprot/parser.go`
- [Text responses](https://github.com/netflix/rend/blob/master/protocol/textprot/respond.go): `protocol/textprot/respond.go`
- [Binary responses](https://github.com/netflix/rend/blob/master/protocol/binprot/respond.go): `protocol/binprot/respond.go`

### Request orchestration

- [L1-only logic](https://github.com/netflix/rend/blob/master/orcas/l1only.go): `orcas/l1only.go`
- [L1/L2 logic](https://github.com/netflix/rend/blob/master/orcas/l1l2.go): `orcas/l1l2.go`
- [Batch L1/L2 logic](https://github.com/netflix/rend/blob/master/orcas/l1l2batch.go): `orcas/l1l2batch.go`

### Storage handlers

- [In-memory handler](https://github.com/netflix/rend/blob/master/handlers/inmem/inmem.go): `handlers/inmem/inmem.go`
- [Memcached handler](https://github.com/netflix/rend/blob/master/handlers/memcached/std/handler.go): `handlers/memcached/std/handler.go`
- [Batched handler](https://github.com/netflix/rend/blob/master/handlers/memcached/batched/handler.go): `handlers/memcached/batched/handler.go`
- [Batch connections](https://github.com/netflix/rend/blob/master/handlers/memcached/batched/conn.go): `handlers/memcached/batched/conn.go`
- [Chunked handler](https://github.com/netflix/rend/blob/master/handlers/memcached/chunked/handler.go): `handlers/memcached/chunked/handler.go`

### Client tools

- [Load and correctness clients](https://github.com/netflix/rend/blob/master/client/cmd/blast/main.go): `client/cmd/blast/main.go`
- [Binary client protocol](https://github.com/netflix/rend/blob/master/client/binprot/prot.go): `client/binprot/prot.go`
- [Text client protocol](https://github.com/netflix/rend/blob/master/client/textprot/prot.go): `client/textprot/prot.go`

### Shared instrumentation

- [Metrics library](https://github.com/netflix/rend/blob/master/metrics/endpoint.go): `metrics/endpoint.go`
- [Timing utility](https://github.com/netflix/rend/blob/master/timer/timer.go): `timer/timer.go`

### Other components

- **Memcached client**
- **Memcached backend**

## Connections

- Memcached client → Connection listener: connects to
- Server configuration → Connection listener: configures (evidence: `memproxy.go`)
- Server configuration → L1-only logic: selects (evidence: `memproxy.go`)
- Server configuration → L1/L2 logic: selects (evidence: `memproxy.go`)
- Server configuration → Memcached handler: selects (evidence: `memproxy.go`)
- Server configuration → Batched handler: selects (evidence: `memproxy.go`)
- Server configuration → Chunked handler: selects (evidence: `memproxy.go`)
- Server configuration → In-memory handler: selects (evidence: `memproxy.go`)
- Connection listener → Default server: uses (evidence: `server/listen.go`)
- Connection listener → Text parser: routes requests
- Connection listener → Binary parser: routes requests
- Default server → L1-only logic: dispatches (evidence: `server/default.go`)
- Default server → L1/L2 logic: dispatches (evidence: `server/default.go`)
- Text parser → Text responses: formats replies
- Binary parser → Binary responses: formats replies
- L1-only logic → In-memory handler: dispatches (evidence: `orcas/l1only.go`)
- L1-only logic → Memcached handler: dispatches
- L1/L2 logic → Memcached handler: dispatches
- Batch L1/L2 logic → Memcached handler: dispatches
- Batch L1/L2 logic → Batched handler: dispatches
- Batched handler → Batch connections: uses (evidence: `handlers/memcached/batched/handler.go`)
- Memcached handler → Memcached backend: sends commands (evidence: `handlers/memcached/std/handler.go`)
- Batch connections → Memcached backend: sends batches (evidence: `handlers/memcached/batched/conn.go`)
- Chunked handler → Memcached backend: stores chunks (evidence: `handlers/memcached/chunked/handler.go`)
- Load and correctness clients → Binary client protocol: uses (evidence: `client/cmd/blast/main.go`)
- Load and correctness clients → Text client protocol: uses (evidence: `client/cmd/blast/main.go`)
- Load and correctness clients → Memcached client: sends requests
- Load and correctness clients → Timing utility: measures duration (evidence: `client/cmd/blast/main.go`)
- L1/L2 logic → Metrics library: records (evidence: `orcas/l1l2.go`)
- Memcached handler → Metrics library: records (evidence: `handlers/memcached/std/handler.go`)
- Binary parser → Metrics library: records (evidence: `protocol/binprot/parser.go`)
- Text parser → Timing utility: timestamps requests (evidence: `protocol/textprot/parser.go`)
