DEV Community

Michael Salaverry
Michael Salaverry

Posted on

FastGRPC - FastAPI with the speed of gRPC

FastGRPC

CI

Add gRPC to your FastAPI app in one line. No protobuf. No config. ~2× faster than HTTP/JSON.

The Pitch

You already have a FastAPI app. FastGRPC reads it at startup and gives you a fully working gRPC server — same handlers, same Pydantic models, zero new files to write or maintain.

from fastgrpc import FastGRPC

# Your existing FastAPI app, unchanged
app = FastAPI()

@app.get("/items/{item_id}", response_model=Item)
async def get_item(item_id: int) -> Item:
    ...

# One line to add gRPC on port 50051
FastGRPC(app, grpc_port=50051)
Enter fullscreen mode Exit fullscreen mode

That's the entire migration.

Performance

Benchmarked on the same FastAPI app, same handler logic, 30,000 requests over ~1 minute with persistent connections (how production clients work):

Scenario HTTP/JSON gRPC Speedup
Small payload (3 fields) 5.38 ms 1.18 ms 4.6×
Large payload (~50 fields, nested)

Top comments (0)