This document outlines the design of a unified protocol abstraction layer that enables both server and client operations over our high-performance networking stack (io_uring, DPDK, RDMA, AF_XDP, etc.).
- Architecture Overview
- Dedicated I/O Workers Pattern
- Protocol Trait Design
- Transport Abstraction
- Protocol Implementations
- Connection Management
- Integration with Worker Pool
- Request/Response Patterns
- Performance Considerations
- Security & Authentication
┌─────────────────────────────────────────────────────────────┐
│ Application Workers │
│ (Business Logic, Data Processing) │
└─────────────────────────────────────────────────────────────┘
▲ │
│ │ Messages (Application Protocol)
│ ▼
┌─────────────────────────────────────────────────────────────┐
│ Dedicated I/O Workers │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Server I/O │ │ Client I/O │ │
│ │ Workers │ │ Workers │ │
│ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
▲ │
│ │ Protocol Layer (HTTP, gRPC, etc.)
│ ▼
┌─────────────────────────────────────────────────────────────┐
│ Transport Abstraction Layer │
│ (Unified interface over io_uring/DPDK/RDMA/AF_XDP) │
└─────────────────────────────────────────────────────────────┘
▲ │
│ │ Raw bytes
│ ▼
┌─────────────────────────────────────────────────────────────┐
│ Low-Level Networking Stack │
│ io_uring │ DPDK │ RDMA │ AF_XDP │ Raw Sockets │ eBPF │
└─────────────────────────────────────────────────────────────┘
- Separation of Concerns: Application workers focus on business logic, I/O workers handle networking
- Protocol Abstraction: Common traits for all application protocols (HTTP, gRPC, Redis, PostgreSQL, etc.)
- Transport Independence: Protocols work over any transport (io_uring, DPDK, RDMA)
- Zero-Copy: Minimize data copying between layers
- Bidirectional: Same infrastructure for server (inbound) and client (outbound)
- Composable: Mix different protocols in same application
Instead of each application worker doing its own I/O, we create specialized I/O workers that:
- Handle all network operations (both server and client)
- Run on dedicated CPU cores
- Use high-performance networking stack
- Communicate with application workers via message passing
Performance:
- CPU affinity: I/O workers pinned to specific cores
- Cache locality: Network buffers stay in I/O worker cache
- Reduced context switching
- Better utilization of hardware acceleration
Isolation:
- Network failures don't crash application workers
- Circuit breakers at I/O layer
- Rate limiting centralized
- Security boundary
Scalability:
- Independent scaling of I/O and application workers
- Multiple I/O workers per transport
- Load balancing across I/O workers
Flexibility:
- Swap transports without changing application
- Protocol versioning isolated
- A/B testing protocols
- Multi-datacenter routing
- Accept incoming connections
- Parse requests (HTTP, gRPC, custom protocols)
- Route to application workers
- Send responses back to clients
- Establish connections to external systems
- Send requests (HTTP APIs, databases, message queues)
- Receive responses
- Route responses to application workers
- Handle both inbound and outbound
- Useful for proxy/gateway scenarios
- Request forwarding
Typical Server Setup (64-core machine):
Cores 0-3: Server I/O Workers (inbound traffic)
Cores 4-7: Client I/O Workers (outbound traffic)
Cores 8-63: Application Workers (business logic)
Cores 62-63: System/Monitoring
Considerations:
- NUMA-aware allocation
- Avoid hyperthreads for I/O workers (use physical cores)
- Reserve cores for kernel (IRQ handling)
- Isolate using
isolcpusor cgroups
Abstraction over all networking backends:
Trait: Transport
- Unified interface over io_uring, DPDK, RDMA, AF_XDP
- Raw byte send/receive
- Connection lifecycle
- Zero-copy buffer management
Operations:
send(bytes): Send raw bytesrecv(): Receive raw bytessend_vectored(iovec): Scatter-gather sendrecv_vectored(iovec): Scatter-gather receivezero_copy_send(buffer): Zero-copy transmissionclose(): Close connectionpoll(): Non-blocking check for data
Implementations:
IoUringTransport: io_uring backendDpdkTransport: DPDK backendRdmaTransport: RDMA backendAfXdpTransport: AF_XDP backendRawSocketTransport: Raw sockets backendMioTransport: mio/epoll backend (fallback)
Connection Types:
Stream: TCP-like (connection-oriented)Datagram: UDP-like (connectionless)SeqPacket: Ordered, reliable, message-oriented
Abstraction for application protocols:
Trait: Protocol
- Parse/serialize application messages
- Handle protocol-specific logic
- Transport-independent
Operations:
parse_request(bytes) -> Request: Deserialize requestserialize_request(request) -> bytes: Serialize requestparse_response(bytes) -> Response: Deserialize responseserialize_response(response) -> bytes: Serialize responseprotocol_name(): Identifier (e.g., "HTTP/1.1", "gRPC")default_port(): Standard port
Metadata:
is_binary(): Binary vs text protocolsupports_streaming(): Streaming capabilityrequires_tls(): Security requirementsmultiplexing_support(): Connection multiplexing (HTTP/2, QUIC)
Server-specific protocol operations:
Trait: ServerProtocol: Protocol
- Accept and handle incoming requests
- Generate responses
Operations:
handle_connection(transport): Handle new connectionprocess_request(request) -> response: Application logic hookerror_response(error) -> response: Error handlinghealth_check_response(): Health endpointconnection_timeout(): Idle connection timeoutmax_request_size(): Request size limits
Lifecycle Hooks:
on_connect(connection_info): New connectionon_disconnect(connection_info): Connection closedon_error(error): Error occurredon_timeout(): Request timeout
State Management:
connection_state(): Per-connection statesession_management(): Session handlingrate_limiting(): Per-connection rate limits
Client-specific protocol operations:
Trait: ClientProtocol: Protocol
- Establish outbound connections
- Send requests and receive responses
Operations:
connect(address) -> connection: Establish connectionsend_request(request): Send requestrecv_response() -> response: Receive responsecall(request) -> response: Synchronous request-responseasync_call(request) -> future<response>: Async request-response
Connection Management:
connection_pool(): Connection poolingmax_connections(): Pool sizeconnection_timeout(): Connect timeoutrequest_timeout(): Request timeoutretry_policy(): Retry configuration
Reliability:
circuit_breaker(): Circuit breaker statebackoff_strategy(): Exponential backoffhealth_check(): Connection healthfailover_strategy(): Failover logic
For protocols that are both client and server:
Trait: BidirectionalProtocol: ServerProtocol + ClientProtocol
- Full-duplex communication
- Peer-to-peer scenarios
Use Cases:
- WebSocket (both send and receive)
- gRPC bidirectional streaming
- Database replication protocols
- P2P protocols
All protocols implement a state machine:
States:
- Disconnected: No connection
- Connecting: Connection establishment in progress
- Connected: Connection established, ready
- Authenticating: Authentication/handshake in progress
- Ready: Authenticated, can send/receive
- Closing: Graceful shutdown in progress
- Closed: Connection closed
- Error: Error state
Transitions:
- State transitions triggered by events
- Thread-safe state management
- Observers for state changes
- Metrics on state transitions
The transport layer provides a consistent API across all networking backends.
Connection Properties:
local_address(): Local endpointremote_address(): Remote endpointconnection_id(): Unique identifierprotocol(): Transport protocol (TCP, UDP, RDMA, etc.)
Performance Properties:
mtu(): Maximum transmission unitbandwidth(): Available bandwidthlatency(): Round-trip timebuffer_size(): Send/receive buffer sizes
Capability Properties:
supports_zero_copy(): Zero-copy capabilitysupports_vectored_io(): Scatter-gathersupports_tls(): TLS offloadsupports_checksumming(): Hardware checksum offload
Automatic Selection:
Decision factors:
1. Hardware availability (RDMA NIC, DPDK-capable NIC)
2. Destination (local, same datacenter, remote)
3. Protocol requirements (latency-sensitive, throughput-oriented)
4. Security requirements (TLS, encryption)
5. Configuration preferences
Selection Algorithm:
- Ultra-low latency (< 10µs): RDMA
- High packet rate (> 10Mpps): DPDK or AF_XDP
- Efficient I/O (< 100µs): io_uring
- Standard (compatibility): mio/epoll
- Fallback: Standard sockets
Manual Override:
- Configuration file
- Environment variables
- Runtime API
- Per-connection selection
Server Implementation:
- Request parsing: Method, path, headers, body
- Response generation: Status, headers, body
- Keep-alive support
- Chunked transfer encoding
- Connection pipelining
Client Implementation:
- Request building: Method, URL, headers, body
- Response parsing: Status, headers, body
- Connection pooling
- Keep-alive
- Automatic retries
Features:
- Header compression (not built-in)
- Body streaming
- Multipart forms
- WebSocket upgrade
Performance:
- Zero-copy body transfers
- Header caching
- Connection reuse
- Minimal allocations
Server Implementation:
- Binary framing
- Stream multiplexing
- Server push
- Header compression (HPACK)
- Flow control
Client Implementation:
- Stream management
- Priority handling
- Header compression
- Connection pooling (one connection per host)
Features:
- Full multiplexing
- Request prioritization
- Server push support
- Better compression
Performance:
- Single connection per host
- Reduced head-of-line blocking
- Better bandwidth utilization
- Lower latency
Server Implementation:
- UDP-based transport
- QUIC connection management
- Stream multiplexing
- 0-RTT connection establishment
Client Implementation:
- QUIC client
- Connection migration
- 0-RTT resumption
Features:
- No head-of-line blocking
- Connection migration
- Fast connection establishment
- Built-in encryption
Challenges:
- Requires UDP support in transport
- Userspace congestion control
- More complex implementation
Overview:
- HTTP/2 based
- Protocol Buffers
- Bidirectional streaming
Server Implementation:
- Service definition
- Method dispatch
- Streaming handlers
- Interceptors/middleware
Client Implementation:
- Stub generation
- Channel management
- Load balancing
- Retry/deadline handling
Streaming Types:
- Unary: Single request, single response
- Server streaming: Single request, stream responses
- Client streaming: Stream requests, single response
- Bidirectional: Both stream
Features:
- Type-safe APIs
- Efficient binary protocol
- Good tooling
- Language interop
Performance:
- HTTP/2 multiplexing
- Protobuf efficiency
- Streaming large datasets
- Connection reuse
Overview:
- Simple text-based protocol
- Request-response pattern
- Pipelining support
Server Implementation:
- RESP parser
- Command dispatch
- Pipelining
- Pub/sub
Client Implementation:
- Command builder
- Response parser
- Connection pooling
- Pipelining
Features:
- Simple implementation
- Human-readable (debugging)
- Fast parsing
- Multiplexing (pub/sub)
Performance:
- Minimal overhead
- Pipelining for throughput
- Connection pooling
Overview:
- Binary protocol
- Extended query protocol
- Prepared statements
Server Implementation:
- Authentication (SASL, MD5)
- Query parsing
- Result set encoding
- Transaction management
Client Implementation:
- Connection establishment
- Authentication
- Query execution
- Result parsing
- Prepared statements
- Connection pooling
Features:
- Binary format (efficient)
- Prepared statements (SQL injection protection)
- Transactions
- COPY protocol (bulk data)
Performance:
- Binary encoding (faster than text)
- Prepared statement caching
- Connection pooling
- Batch operations
Overview:
- Binary protocol
- Producer/consumer pattern
- Topic partitioning
Client Implementation (Producer):
- Topic discovery
- Partition assignment
- Message batching
- Compression
- Acknowledgment handling
Client Implementation (Consumer):
- Group coordination
- Partition assignment
- Offset management
- Message fetching
Features:
- High throughput
- Durability
- Ordering guarantees
- Consumer groups
Performance:
- Batching
- Compression
- Zero-copy (sendfile)
- Partition parallelism
Design Considerations:
- Message framing (length-prefixed, delimiter-based)
- Serialization format (Protobuf, MessagePack, Bincode, CBOR)
- Versioning (protocol version negotiation)
- Error handling
- Flow control
Best Practices:
- Length-prefix messages (avoid scanning)
- Binary encoding (efficiency)
- Type-safe serialization (Serde)
- Version field in header
- Checksum/CRC for corruption detection
Goals:
- Reuse connections (amortize setup cost)
- Limit concurrent connections
- Health checking
- Fair distribution
Pool Types:
- Pre-allocated connections
- Block when exhausted
- Predictable resource usage
- Simple implementation
- Grow/shrink based on demand
- Min/max limits
- Connection timeout
- More complex
- Each I/O worker has own pool
- No contention between workers
- More total connections
- Better locality
- All workers share pool
- Fewer total connections
- Requires synchronization
- Better utilization
Pool Management:
- Health checks (periodic ping)
- Idle timeout (close unused)
- Max lifetime (rotate connections)
- Connection validation
- Metrics (pool size, wait time)
States:
- Closed: Normal operation
- Open: Fail fast (don't try)
- Half-Open: Testing recovery
Per-Destination Circuit Breakers:
- Track failures per endpoint
- Independent breakers
- Prevent cascading failures
Failure Detection:
- Connection timeouts
- Request timeouts
- Error responses (5xx)
- Network errors
Recovery:
- Exponential backoff
- Test requests
- Gradual ramp-up
Integration Points:
- DNS (traditional)
- Consul
- etcd
- Kubernetes services
- Custom registry
Resolution:
- Periodic refresh
- Push-based updates
- Health-based filtering
- Load balancing
1. Client → Network → Server I/O Worker
- I/O worker receives bytes
- Parse protocol (HTTP request)
- Create message envelope
2. Server I/O Worker → Application Worker
- Route based on partitioning
- Send via high-performance channel
- Include connection context
3. Application Worker processes request
- Business logic
- Database queries (via Client I/O Workers)
- Computation
4. Application Worker → Server I/O Worker
- Send response message
- Include connection ID
5. Server I/O Worker → Network → Client
- Serialize response
- Send over transport
- Close or keep-alive connection
1. Application Worker → Client I/O Worker
- Send request message
- Specify destination
- Include callback/correlation ID
2. Client I/O Worker → Network → External Service
- Get connection from pool
- Serialize request
- Send via transport
- Wait for response (async)
3. External Service → Network → Client I/O Worker
- Receive response bytes
- Parse protocol
- Create response message
4. Client I/O Worker → Application Worker
- Route using correlation ID
- Send via channel
- Return connection to pool
Synchronous (blocking):
- Application worker sends request
- Blocks waiting for response
- Simple but limits throughput
Asynchronous (non-blocking):
- Application worker sends request with correlation ID
- Continues processing
- I/O worker replies with correlation ID
- Application worker matches response
Use Case: Logging, metrics, events
- Application worker sends message
- No response expected
- I/O worker handles delivery
- Best effort or reliable
Server Streaming:
- Single request
- Multiple responses
- I/O worker buffers/controls flow
Client Streaming:
- Multiple requests
- Single response
- Application worker sends stream
- I/O worker batches
Bidirectional:
- Both directions stream
- WebSocket, gRPC bidirectional
- Complex coordination
Fan-Out/Fan-In:
- Application worker makes multiple requests
- Different destinations
- I/O workers handle concurrently
- Aggregate responses
Correlation ID:
- Unique per request-response pair
- Generated by application worker
- Included in messages
- Used for routing responses
Request Context:
- Trace ID (distributed tracing)
- User/session ID
- Priority
- Deadline
- Metadata (headers, auth)
Context Propagation:
- Passed through all layers
- Preserved in I/O workers
- Included in external requests
- Logged for debugging
Levels:
- Connection Timeout: How long to wait for connection
- Request Timeout: Total request duration
- Idle Timeout: Inactivity timeout
- Keep-Alive Timeout: Connection reuse timeout
Timeout Implementation:
- Timer wheels (efficient)
- Per-request deadlines
- Timeout propagation
- Partial results
Timeout Response:
- Return error to application worker
- Circuit breaker integration
- Retry decision
- Logging/metrics
Retry Strategies:
- Fixed Delay: Wait fixed time between retries
- Exponential Backoff: Increasing delays
- Jittered Backoff: Add randomness (thundering herd)
- Adaptive: Based on observed latency
Retry Conditions:
- Network errors (connection refused, timeout)
- Transient errors (503, 429)
- Idempotent operations only
- Not for non-idempotent (POST)
Retry Limits:
- Max retry count
- Max total time
- Budget-based (time/cost)
Retry Context:
- Track retry attempts
- Log for debugging
- Metrics per retry
- Circuit breaker interaction
Producer Side (Application Workers):
- Slow down if I/O workers overwhelmed
- Queue depth monitoring
- Reject or queue requests
I/O Worker Side:
- Signal backpressure to application workers
- Flow control at protocol level (HTTP/2, gRPC)
- Buffer management
Network Side:
- TCP flow control
- RDMA flow control
- Application-level flow control
Strategies:
- Direct Buffer Sharing: Share buffers between layers
- Memory Mapping: mmap for large data
- sendfile/splice: Kernel zero-copy
- RDMA: Hardware zero-copy
- io_uring: Zero-copy send/recv
Buffer Management:
- Pre-allocated buffer pools
- Fixed-size buffers (avoid fragmentation)
- Reference counting (shared buffers)
- Arena allocation
Request Batching:
- Combine multiple small requests
- Reduce per-request overhead
- Vectored I/O (sendmsg with iovec)
Response Batching:
- Buffer multiple responses
- Flush on timeout or size
- Amortize send overhead
Benefits:
- Fewer syscalls
- Better cache utilization
- Higher throughput
- Lower CPU usage
Trade-offs:
- Increased latency
- Memory usage
- Complexity
I/O Worker Placement:
- Pin to cores near NIC
- Same NUMA node as NIC
- Avoid core migration
Application Worker Placement:
- Distribute across NUMA nodes
- Keep data local
- Minimize cross-node traffic
Memory Allocation:
- Allocate on same NUMA node
- Use
numa_alloc_onnode() - Monitor cross-node access
Between Workers:
- Use lock-free channels (crossbeam)
- SPSC when possible (fastest)
- MPSC for fan-in
- MPMC when necessary
Within I/O Workers:
- Lock-free data structures
- Per-connection state isolated
- Atomic operations for shared state
Server-Side TLS:
- Certificate management
- SNI (Server Name Indication)
- ALPN (Application-Layer Protocol Negotiation)
- Session resumption
- Client certificates (mTLS)
Client-Side TLS:
- Certificate validation
- CA certificate bundle
- Hostname verification
- Certificate pinning
- Custom validators
TLS Offload:
- Hardware acceleration (QAT)
- TLS termination at load balancer
- End-to-end encryption
Performance:
- Session reuse (reduce handshakes)
- TLS 1.3 (faster handshake)
- Hardware acceleration
- Connection pooling
HTTP Authentication:
- Basic auth (base64 encoded)
- Bearer tokens (JWT)
- OAuth 2.0
- API keys
Database Authentication:
- Username/password
- SASL (PostgreSQL)
- IAM (AWS RDS)
- Certificate-based
gRPC Authentication:
- Metadata (headers)
- TLS certificates
- JWT tokens
- Interceptors
Custom Authentication:
- Protocol-specific handshake
- Challenge-response
- Token exchange
- Session management
Levels:
- Connection-level: Who can connect?
- Operation-level: What operations allowed?
- Resource-level: What data accessible?
Integration:
- Policy enforcement in I/O workers
- Context propagation to application workers
- Centralized policy service
- Caching for performance
Deliverables:
- Transport trait definition
- Protocol trait hierarchy
- Basic transport implementations (io_uring, mio)
- Simple protocol (HTTP/1.1 client)
- Connection pooling
Validation:
- Unit tests for traits
- Integration tests (echo server/client)
- Benchmark transport overhead
- Verify zero-copy paths
Deliverables:
- HTTP/1.1 server and client (full)
- HTTP/2 support
- gRPC protocol
- Redis protocol (RESP)
- Circuit breaker integration
Validation:
- HTTP benchmark vs nginx/hyper
- gRPC benchmark vs tonic
- Redis benchmark vs official client
- Interop tests with real servers
Deliverables:
- DPDK transport
- RDMA transport
- AF_XDP transport
- Transport auto-selection
- Performance tuning
Validation:
- Benchmark each transport
- Compare latency/throughput
- Test failover scenarios
- Production load testing
Deliverables:
- PostgreSQL protocol
- Kafka protocol
- TLS integration (rustls)
- Service discovery
- Advanced monitoring
Validation:
- Real-world application integration
- Security audit
- Performance validation
- Documentation
Deliverables:
- Zero-copy optimizations
- NUMA-aware allocation
- Hardware acceleration (QAT for TLS)
- Protocol-specific optimizations
- Profiling and tuning
Validation:
- Performance benchmarks
- Comparison with best-in-class
- Real production workloads
- Scalability testing
| Protocol | Server | Client | Streaming | Multiplexing | Zero-Copy | TLS | Complexity |
|---|---|---|---|---|---|---|---|
| HTTP/1.1 | ✅ | ✅ | Partial | No | ✅ | ✅ | Low |
| HTTP/2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | Medium |
| HTTP/3 | ✅ | ✅ | ✅ | ✅ | ✅ | Required | High |
| gRPC | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | Medium |
| Redis (RESP) | ✅ | ✅ | Pub/Sub | Pipelining | ✅ | Optional | Low |
| PostgreSQL | ✅ | ✅ | Cursors | No | ✅ | ✅ | High |
| MySQL | ✅ | ✅ | No | No | ✅ | ✅ | Medium |
| MongoDB | ✅ | ✅ | Cursors | No | ✅ | ✅ | Medium |
| Kafka | N/A | ✅ | ✅ | Partitions | ✅ | ✅ | High |
| RabbitMQ (AMQP) | ✅ | ✅ | ✅ | Channels | ✅ | ✅ | High |
| WebSocket | ✅ | ✅ | ✅ | No | ✅ | ✅ | Medium |
| Custom Binary | ✅ | ✅ | ✅ | Custom | ✅ | ✅ | Variable |
| Transport | Latency | Throughput | Complexity | Maturity | Use Case |
|---|---|---|---|---|---|
| io_uring | ~10µs | 10M ops/s | Medium | Mature | General purpose |
| DPDK | ~5µs | 20M pps | High | Very Mature | Packet processing |
| RDMA | ~1µs | 100 Gbps | High | Mature | Ultra-low latency |
| AF_XDP | ~5µs | 10M pps | High | Maturing | Packet processing |
| Raw Sockets | ~20µs | 1M ops/s | Medium | Mature | Custom protocols |
| eBPF/XDP | ~2µs | 24M pps | Very High | Maturing | Filtering/routing |
| mio/epoll | ~50µs | 100K ops/s | Low | Very Mature | Fallback |
Use Case: Translate between protocols
Example: HTTP REST API → gRPC backend
Flow:
1. Server I/O Worker: Receive HTTP request
2. Application Worker: Translate REST → gRPC
3. Client I/O Worker: Send gRPC request
4. Client I/O Worker: Receive gRPC response
5. Application Worker: Translate gRPC → REST
6. Server I/O Worker: Send HTTP response
Benefits:
- Protocol translation isolated
- Both sides use optimal protocol
- Can cache/optimize translations
Use Case: Fan-out/fan-in for parallel requests
Example: Dashboard fetching from multiple services
Flow:
1. Server I/O Worker: Receive single HTTP request
2. Application Worker: Split into N sub-requests
3. Client I/O Worker: Send N requests (different destinations)
4. Client I/O Worker: Receive N responses
5. Application Worker: Aggregate results
6. Server I/O Worker: Send single HTTP response
Benefits:
- Parallel execution
- Lower latency than sequential
- Circuit breaker per destination
Use Case: Multiple logical channels over one connection
Example: HTTP/2 streams, gRPC
Mechanism:
- Single physical connection
- Multiple logical streams/channels
- Stream IDs for demultiplexing
- Independent flow control per stream
Benefits:
- Fewer connections (resource efficiency)
- Reduced latency (no connection setup)
- Better bandwidth utilization
Use Case: Reuse connections to frequently accessed services
Implementation:
- Client I/O Worker maintains pools
- One pool per destination
- Health checking
- Automatic scaling
Benefits:
- Amortize connection setup
- Predictable performance
- Resource limits
Use Case: Reliability for external calls
Implementation:
- Client I/O Worker implements retry logic
- Circuit breaker per destination
- Transparent to application workers
Benefits:
- Centralized reliability patterns
- Application logic stays simple
- Consistent behavior across protocols
Per I/O Worker:
- Active connections
- Requests/sec
- Bytes sent/received
- Errors/sec
- Latency (p50, p95, p99, p999)
- Queue depth
Per Protocol:
- Protocol-specific metrics (HTTP status codes, gRPC methods)
- Parse errors
- Protocol version distribution
Per Connection:
- Connection lifetime
- Requests per connection
- Keep-alive success rate
- Timeout rate
Per Transport:
- Transport-specific metrics (RDMA operations, DPDK packet drops)
- Hardware counters
- Buffer utilization
Distributed Tracing:
- Propagate trace context through all layers
- Span per I/O operation
- Parent-child relationships
Trace Context:
- W3C Trace Context standard
- Baggage for metadata
- Sampling decisions
Instrumentation Points:
- Request arrival at I/O worker
- Message to application worker
- Application worker processing
- Outbound request to external system
- Response received
- Response sent to client
Structured Logging:
- JSON format
- Consistent fields (worker_id, connection_id, protocol, etc.)
- Log levels appropriate
Key Events to Log:
- Connection establishment/close
- Protocol errors
- Timeout events
- Circuit breaker state changes
- Slow requests (above threshold)
- Authentication failures
Transport Layer:
- Send/receive correctness
- Error handling
- Buffer management
- Zero-copy paths
Protocol Layer:
- Parse/serialize correctness
- Edge cases (malformed input)
- State machine transitions
- Error responses
Connection Management:
- Pool behavior (acquire/release)
- Health checking
- Timeout handling
- Circuit breaker logic
End-to-End:
- Real protocol implementations
- Against real servers (HTTP, Redis, PostgreSQL)
- Interoperability validation
Performance:
- Latency measurements
- Throughput benchmarks
- Scalability tests
- Resource usage
Reliability:
- Failure injection
- Timeout scenarios
- Circuit breaker activation
- Retry logic validation
Network Failures:
- Packet loss
- Latency injection
- Connection drops
- DNS failures
Service Failures:
- Backend crashes
- Slow responses
- Error responses
- Partial failures
Validation:
- System remains stable
- Circuit breakers activate
- Retries work correctly
- No cascading failures
Scenario: High-performance HTTP API gateway
Architecture:
- Server I/O Workers: Accept HTTP requests (HTTP/2)
- Application Workers: Routing logic, authentication, rate limiting
- Client I/O Workers: Forward to backend services (gRPC)
Transport:
- Inbound: io_uring or DPDK (high connection count)
- Outbound: io_uring (gRPC to backends)
Features:
- TLS termination
- JWT validation
- Circuit breakers per backend
- Request/response transformation
- Load balancing
Scenario: Connection pooling proxy for PostgreSQL
Architecture:
- Server I/O Workers: Accept PostgreSQL protocol connections
- Application Workers: Query routing, caching, rewriting
- Client I/O Workers: Connection pool to real databases
Transport:
- Both: io_uring (efficient I/O)
Features:
- Connection pooling (reduce DB connections)
- Query caching
- Read/write splitting
- Circuit breaker for DB failures
- Connection migration
Scenario: High-throughput Kafka consumer
Architecture:
- Client I/O Workers: Consume from Kafka topics
- Application Workers: Message processing
- Client I/O Workers: Write results (HTTP API, database)
Transport:
- Kafka: io_uring (high throughput)
- Outputs: io_uring
Features:
- Parallel partition consumption
- Offset management
- Backpressure handling
- Error handling/DLQ
- At-least-once or exactly-once
Scenario: Layer 7 load balancer
Architecture:
- Server I/O Workers: Accept connections (HTTP, TLS)
- Application Workers: Minimal (routing only)
- Client I/O Workers: Forward to backends
Transport:
- Inbound: DPDK or AF_XDP (ultra-high packet rate)
- Outbound: io_uring (backend connections)
Features:
- Connection pooling to backends
- Health checking
- Load balancing algorithms
- TLS termination/passthrough
- Zero-copy where possible
Scenario: Stream processing for real-time analytics
Architecture:
- Client I/O Workers: Ingest from sources (Kafka, HTTP streaming)
- Application Workers: Processing, aggregation, windowing
- Client I/O Workers: Write to outputs (database, Kafka)
Transport:
- All: io_uring (balanced performance)
Features:
- Streaming protocols
- Backpressure management
- State checkpointing
- Exactly-once processing
- Low latency
This protocol layer design provides:
✅ Unified Abstraction: Common traits for all protocols
✅ Transport Independence: Works over io_uring, DPDK, RDMA, etc.
✅ Bidirectional: Server and client in same framework
✅ High Performance: Zero-copy, lock-free, NUMA-aware
✅ Reliable: Circuit breakers, retries, timeouts
✅ Observable: Metrics, tracing, logging
✅ Flexible: Multiple protocols, transports, patterns
✅ Production-Ready: Security, authentication, monitoring
- Implement core traits (Transport, Protocol)
- Build reference implementation (HTTP/1.1 over io_uring)
- Validate with benchmarks (compare to hyper, nginx)
- Add more protocols (HTTP/2, gRPC, Redis)
- Integrate with worker pool (dedicated I/O workers)
- Add advanced transports (DPDK, RDMA)
- Production hardening (monitoring, testing, docs)
Document Version: 1.0
Last Updated: October 31, 2025
Status: Design Complete - Ready for Implementation