Railscale

High-performance Rust HTTP reverse proxy built on zero-cost abstractions. All generics are monomorphized — no trait objects or vtable dispatch in the hot path.

Workspace Structure

CrateRole
train_trackCore framework: protocol-agnostic traits, Pipeline orchestrator, routing, error types
carriagesProtocol implementations: HTTP parsing/rewriting, TCP source/destination/router
pocPython proof-of-concept (historical)
conductorFuture orchestration layer (stub)

Architecture

Client -> TcpSource::accept()
       -> FrameParser::parse() (async Stream<ParsedData>)
       -> FramePipeline::process() (header rewriting)
       -> DestinationRouter::route() (concurrent with parsing)
       -> StreamDestination::write() (forward bytes)
       -> StreamDestination::relay_response() (pipe back to client)

Concurrent Pipeline

Once the first routing frame arrives, do_connection uses tokio::join! to route (connect upstream) in parallel with continued frame parsing. See Railscale Connection Lifecycle.

Key Design Decisions

  • Protocol-agnostic destinations: StreamDestination writes Bytes, not Frame. Protocol knowledge stays in the parser/pipeline layer.
  • First-class routing: DestinationRouter trait is an async factory that produces connected destinations from routing keys (&[u8]).
  • SIMD domain matching: MatchStrategy uses memchr/memmem for Exact/Suffix/Prefix/Contains matching.
  • Parallel header rewriting: HttpPipeline uses rayon for concurrent header matching across rules.
  • Monomorphized generics: Pipeline<Src, Par, Pip, Rtr> — compiler generates specialized code per concrete type combination.

Performance

At 500 req/s against a local upstream (2-byte response):

  • p50: ~436us
  • p99: ~2.5ms
  • 99.98% success rate

Feature Flags

  • metrics-minimal — OpenTelemetry counters and histograms
  • metrics-full — Per-request sampler with detailed timing breakdown