khone/koʊ.neɪ/
Experimental

LMI deployment model

Khone runs as a Rust Lambda gateway on Lambda Managed Instances (LMI). The gateway accepts HTTP requests through a response-streaming Lambda Function URL, keeps batching state inside each execution environment, invokes target Lambdas, and demultiplexes responses back to clients.

Client
  |
  | Lambda Function URL, RESPONSE_STREAM
  v
Gateway Lambda on LMI
  |
  | in-memory batch per target, method, route, mode, and key
  v
Target Lambda invocation(s)
  |
  v
Per-request responses -> gateway demux -> client

Two stacks, different owners

The bootstrap stack is shared per account and region. It installs the config bucket, config publisher, CloudFormation macro, Mode A layer artifacts, and versioned gateway Lambda artifact settings.

Application stacks own target functions and supply an existing LMI capacity provider ARN. The Khone::Gateway::Service resource creates the gateway Lambda, Function URL, execution role, and config artifact.

Gateway function

Application templates define the gateway with Khone::Gateway::Service. The macro emits a native AWS::Lambda::Function with:

  • Runtime: provided.al2023
  • PackageType: Zip
  • Architectures: [arm64]
  • AWS::Lambda::Url using InvokeMode: RESPONSE_STREAM
  • CapacityProviderConfig.LambdaManagedInstancesCapacityProviderConfig
  • FunctionScalingConfig
  • KHONE_CONFIG_URI set from the generated config publisher

Use response streaming on the Function URL even when a route invokes buffered targets. The gateway needs the client-facing response stream for routes that do stream.

Execution environments

Each LMI execution environment has its own router, batchers, queues, timers, and probe state. There is no cross-environment coordination. Requests can be batched together only when Lambda routes them to the same execution environment.

Minimum execution environments provide baseline warm capacity. Maximum execution environments bound scale-out and cost exposure.

In-memory state

The gateway keeps short-lived state in memory: queue membership, flush timers, request ids, response channels, request-rate samples, and target-duration probe data. A new execution environment starts without that history, so adaptive and target-aware batching can take a short ramp-up period.

Treat batching state as opportunistic. Deployments, scaling changes, failures, or Lambda lifecycle decisions can replace an environment at any time.

Scale-out effects

When Lambda adds execution environments, traffic is split across independent batchers. Effective batch size may temporarily drop until each environment has enough traffic and probe data.

429 responses can come from gateway request limits, pending invocation limits, target Lambda throttling, or Function URL/Lambda capacity. Use logs and metrics to distinguish them.