I built a zero-dependency API router for AWS Lambda, with a Rust core. Here's what the benchmarks say.

TL;DR: lambroute gives Python Lambda functions FastAPI-style routes, validation and Swagger docs, and in my benchmark of a basic API it cold-starts about 2× faster than Powertools and 6× faster than FastAPI + Mangum (1.8× and 2.3× once Pydantic validation is added). Code and benchmark: github.com/HAPPY-CHANDRU-RAJU/lambroute
Every Python API I put on AWS Lambda ended up with the same trade-off. Either I hand-wrote routing and validation inside one big handler, or I pulled in a full web framework and paid for it on every cold start. I wanted the developer experience of FastAPI with the footprint of a plain handler, so I built lambroute.
Why I built it
As a FastAPI developer, I was used to a framework that provides a clean, structured, and developer-friendly way to build APIs, with built-in routing, method-based handlers, request validation, and automatic Swagger documentation.
But whenever I worked with AWS Lambda, I found myself writing much of this functionality manually. The Lambda programming model felt quite different from the FastAPI experience I was accustomed to. AWS Lambda Powertools provides many useful capabilities, including routing, validation and Swagger UI, but it can feel relatively heavyweight for projects that need only a lightweight API framework (in my benchmark, its API router takes about twice as long to cold-start as lambroute's).
I wanted to bridge this gap by combining the developer experience I love in FastAPI with the simplicity and serverless nature of AWS Lambda.
Python alone could address the developer-experience gap, but I also wanted to explore Rust. I used it for the hot path, route matching, where speed matters most. As the benchmarks below show, most of the start-up gain actually comes from keeping dependencies at zero, not from Rust.
That's why I started building lambroute: a lightweight Python-first AWS Lambda framework, powered by Rust where performance matters.
The goal is simple: bring clean routing, method-based handlers, request validation, and API documentation to AWS Lambda without unnecessary boilerplate or heavyweight dependencies.
What already exists
There are two good, widely used answers today, and lambroute borrows ideas from both.
- Powertools for AWS Lambda (Python) is maintained by AWS. Its event handler does routing, Pydantic validation, OpenAPI generation and Swagger UI, and it supports REST and HTTP APIs, ALB, Function URLs and VPC Lattice. It also brings logging, tracing, metrics and much more. If you already use Powertools, its router is a strong default.
- FastAPI + Mangum lets you run a normal FastAPI app on Lambda. You get FastAPI's full ecosystem, and the same code also runs in a container. The cost is that you load a whole ASGI web stack for every cold start.
lambroute is narrower than both. It only does the API layer, and it tries to do that with as little start-up cost as possible.
What it looks like
If you know FastAPI, lambroute will look familiar:
from pydantic import BaseModel from lambroute import API app = API(title="Shop API", version="1.0.0", swagger=True) class ItemIn(BaseModel): name: str price: float class Item(ItemIn): id: int @app.get("/items/{item_id}", response_model=Item) def get_item(item_id: int): return {"id": item_id, "name": "widget", "price": 9.5} @app.post("/items", response_model=Item, status_code=201) def create_item(body: ItemIn): return {"id": 1, **body.model_dump()} lambda_handler = app # an API instance is a valid Lambda handler Deploy it behind API Gateway and you get:
-
item_idconverted to anint, and a 422 with field-level errors when the body doesn't matchItemIn; - an OpenAPI spec at
/openapi.jsonand Swagger UI at/docs; - the same code working with REST APIs, HTTP APIs (payload 1.0 and 2.0) and Function URLs.
Pydantic is optional. Without it, typed path and query parameters still work, and the only thing you install is lambroute itself.
Design decisions
Rust only where it pays. Route matching (path parsing, a segment trie, method matching, parameter extraction) lives in a small Rust extension built with PyO3. Each request makes exactly one call from Python into Rust. Everything else stays in Python, because converting request and response objects across the boundary would cost more than it saves. On its own, route matching is 2.7–5.3× faster in Rust and stays flat from 10 to 10,000 routes. Across a whole request, that is only a 1.1–1.2× gain, because matching is about 1 µs of a roughly 10 µs pipeline. I'm saying that plainly: Rust is not why lambroute is fast to start.
A pure-Python fallback with identical behaviour. If the native extension can't load on your platform, lambroute uses a Python router instead. A randomised test checks that both engines return the same results.
Zero runtime dependencies. The core needs nothing outside the standard library and doesn't import asyncio unless you write an async route. Pydantic is optional: if it isn't installed, lambroute never imports it. (If it is installed, version 0.1.4 imports it on the first request, even when no route uses a model.) This, not Rust, is where most of the cold-start difference comes from.
One wheel per platform. The extension uses Python's stable ABI, so one wheel covers Python 3.10 to 3.14. Wheels exist for Linux x86_64 and arm64 (glibc for AWS Lambda, musl for Alpine), macOS and Windows.
A supply chain you can verify. Since version 0.1.4, every release is built and published only by GitHub Actions, with PyPI trusted publishing, PEP 740 attestations and GitHub build-provenance attestations.
Benchmarks
I wrote the same small API in all three frameworks, in two versions: a basic one with typed path and query parameters, and one with a Pydantic request body, a response model and Swagger UI. Each version is checked for correct responses, including the 422 on bad input, before it is timed. Cold start means importing the framework, building the app and handling the first request, in a fresh Python process.
| Framework | API | Peak memory | Warm request | Deployment zip |
|---|---|---|---|---|
| lambroute | Basic | 20.5 MB | 12 µs | 0.26 MB |
| Powertools | Basic | 25.7 MB | 21 µs | 1.05 MB |
| FastAPI + Mangum | Basic | 43.0 MB | 113 µs | 3.16 MB |
| lambroute | Pydantic + Swagger | 31.0 MB | 17 µs | 2.94 MB |
| Powertools | Pydantic + Swagger | 39.3 MB | 44 µs | 3.69 MB |
| FastAPI + Mangum | Pydantic + Swagger | 43.2 MB | 108 µs | 3.16 MB |
A bare Python interpreter uses about 18.7 MB, so lambroute's basic app adds under 2 MB. Warm request is the median time for a GET once the function is warm.
How to read this honestly:
- Pydantic is the biggest cost once you use it. Loading it adds about 50 ms to lambroute's start-up, so with validation the lead narrows to 1.8× over Powertools and 2.3× over FastAPI. The package-size advantage mostly disappears too, because Pydantic is most of the zip for everyone.
- Warm requests are measured in microseconds. 12 µs against 113 µs matters little when a database call takes milliseconds.
- These are framework costs, not full Lambda cold starts. Lambda also has to start its runtime, which costs the same for every framework, and download your code, which takes longer for bigger packages. The saving measured here is 30–150 ms of framework start-up on a full CPU core. It is likely larger in real Lambda, because functions with little memory get only part of a CPU.
To keep it fair, FastAPI uses async def endpoints (plain def was about 5× slower per request under Mangum), and every validated app uses the same Pydantic version. Absolute times varied by up to 14% between two full runs, but the ratios moved by less than 2%. The code, raw results and method are in the repo under benchmarks/frameworks/, so you can run it on your own machine.
When not to use it
lambroute is young (version 0.1) and deliberately small. Choose something else if:
- You already use Powertools for logging, tracing and metrics. Its router fits in with those, and AWS maintains it.
- You want the same app to run outside Lambda, in a container or on a server. FastAPI does that, and lambroute doesn't try to.
- You need ALB events, WebSockets or async middleware. lambroute doesn't support these yet.
- Your cold starts are dominated by something else, such as a large ML library or slow database connections. Saving 30–150 ms of framework start-up won't change much there.
It fits best for small and medium JSON APIs on Lambda, where cold-start latency and package size matter and you'd like FastAPI-style code.
Try it
pip install lambroute # core, zero dependencies pip install "lambroute[validation]" # with Pydantic - Code, examples and docs: github.com/HAPPY-CHANDRU-RAJU/lambroute
- Package: pypi.org/project/lambroute
- Benchmark: benchmarks/frameworks. If you get different numbers on your machine or in real Lambda, please open an issue. I'd rather publish corrected numbers than flattering ones.
I'd love feedback, especially from people running Python APIs on Lambda today. What would stop you from trying it? Issues, ideas and "good first issue" pull requests are all welcome.