Choosing a backend framework is one of the technical decisions with the most long-lasting implications in a project. It does not change easily: the code grows around it, the team builds habits on it, integrations depend on it. It’s worth doing it with clarity.
At Marfcode, we work with three backend frameworks: Hono, Fastify, and FastAPI. Not for lack of standards, but because every project has different requirements, and using the wrong tool has a real cost.
The Basic Principle: Language and Context First
Before comparing frameworks, the most important question is: in which language does the backend run, and why?
- If the team is full-stack TypeScript and the backend runs on Cloudflare Workers → Hono
- If the team is Node.js with high throughput requirements and plugin ecosystem → Fastify
- If the backend integrates Python logic, AI models, or data processing → FastAPI
It’s not a question of which framework is “better” in absolute terms. It’s a question of which is more suited to the context. Forcing a Python framework on a TypeScript team, or vice versa, introduces unnecessary friction.
Hono: The Framework for the Edge Era
Hono is an ultra-lightweight (< 15KB) TypeScript/JavaScript web framework designed to run on non-Node.js runtimes: Cloudflare Workers, Deno, Bun, AWS Lambda Edge. The name comes from Japanese for “flame” — fast and lightweight by design.
Why it exists
The problem Hono solves is simple: traditional Node.js frameworks (Express, Fastify) use APIs that do not exist in edge runtimes. require(), fs, path, http — the whole Node.js layer is not available on Cloudflare Workers or Deno. Hono uses only Web Standard APIs (fetch, Request, Response, Headers), which work everywhere.
Technical characteristics
Trie-based router: ultra-fast routing even with hundreds of endpoints. In benchmarks, Hono is among the fastest frameworks available on any runtime.
Middleware pattern: identical to Express (next() pattern), with built-in middleware for CORS, JWT authentication, rate limiting, validation, logging.
Type safety: TypeScript first, with type inference on route parameters and request bodies without manual configuration.
RPC client: Hono can automatically generate a type-safe TypeScript client for its APIs — eliminating the need to maintain a separate API client layer in the frontend.
// Hono on Cloudflare Workers — real example
import { Hono } from "hono";
import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
const app = new Hono();
const createLeadSchema = z.object({
name: z.string().min(2),
email: z.string().email(),
budget: z.number().min(0),
});
app.post("/leads", zValidator("json", createLeadSchema), async (c) => {
const data = c.req.valid("json");
// data is completely typed thanks to Zod
const result = await createLead(data);
return c.json(result, 201);
});
export default app;
When to use Hono
- The backend runs on Cloudflare Workers (edge deployment, minimal global latency)
- The project is full-stack TypeScript, and language and tooling consistency is desired
- Building microservices or lightweight API gateways
- Cold start is a critical requirement (Workers + Hono: cold start < 5ms)
Limits
- Less mature plugin ecosystem compared to Fastify
- Not suitable for CPU-intensive logic (Workers model limit)
- Fewer options for ORMs and databases compared to the full Node.js ecosystem
Fastify: The Node.js Workhorse
Fastify is a Node.js framework built for performance and productivity. The philosophy is “everything has a schema” — input validation, output serialization, and automatic documentation are derived from the same JSON schema.
Technical characteristics
Schema-driven: each endpoint defines a JSON schema for input and output. Fastify uses these definitions to automatically validate incoming requests and serialize responses in an optimized way (3–5x faster than standard JSON serialization with JSON.stringify).
Plugin system: the entire Fastify ecosystem is built on plugins with integrated dependency injection. Support for separating responsibilities is structural, not conventional.
Performance: in Node.js benchmarks, Fastify handles 30,000–60,000 requests/second on standard hardware — significantly more than Express (10,000–15,000 req/s).
Automatic OpenAPI: with @fastify/swagger, OpenAPI documentation is generated automatically from schemas. Zero manual documentation to maintain.
// Fastify — example with schema and plugin
import Fastify from "fastify";
const fastify = Fastify({ logger: true });
fastify.post(
"/orders",
{
schema: {
body: {
type: "object",
required: ["product_id", "quantity"],
properties: {
product_id: { type: "string" },
quantity: { type: "integer", minimum: 1 },
notes: { type: "string" },
},
},
response: {
201: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string" },
created_at: { type: "string", format: "date-time" },
},
},
},
},
},
async (request, reply) => {
const order = await createOrder(request.body);
return reply.code(201).send(order);
}
);
When to use Fastify
- Node.js API with high throughput requirements
- Projects with a Node.js plugin ecosystem (authentication, ORM, messaging)
- Backend that runs on a traditional server or container (not Workers)
- Teams with established Node.js experience that have no reason to move to edge runtimes
- APIs integrating existing Node.js systems (queues, job schedulers, WebSockets)
Limits
- Requires Node.js (does not run on Cloudflare Workers in the standard model)
- The learning curve for the plugin system is steep for those coming from Express
- For Python/AI integrations, it remains a separate system to orchestrate
FastAPI: The Python Backend for the AI Era
FastAPI is the modern Python framework for APIs, built on Starlette (ASGI) and Pydantic. It has become the de facto standard for Python backends in the last three years, passing Flask and Django REST Framework in adoption for new projects.
Technical characteristics
Pydantic for validation: data models are typed Python classes with Pydantic. Input validation, output serialization, and OpenAPI documentation are derived automatically from the same models.
Native async: FastAPI is built on ASGI and supports async/await natively. I/O-intensive operations (calls to databases, external APIs, file systems) do not block the thread.
Automatic documentation: FastAPI automatically generates Swagger UI and ReDoc from Pydantic models. Interactive documentation is always updated without manual effort.
Type hints everywhere: FastAPI uses Python type hints for everything — path parameters, query parameters, bodies, response models. The IDE knows exactly what to expect everywhere.
# FastAPI — example with Pydantic and async
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, EmailStr
from typing import Optional
import asyncio
app = FastAPI()
class RequestAnalysisInput(BaseModel):
text: str
language: str = "en"
mode: Optional[str] = "standard"
class RequestAnalysisOutput(BaseModel):
sentiment: str
categories: list[str]
priority: int
summary: str
@app.post("/analysis/request", response_model=RequestAnalysisOutput)
async def analyze_request(input: RequestAnalysisInput):
# Asynchronous call to AI model
result = await classification_model.analyze(
text=input.text,
language=input.language
)
return RequestAnalysisOutput(**result)
When to use FastAPI
- The backend integrates AI/ML models (LLMs, classifiers, predictive models)
- The Python scientific library is used (NumPy, Pandas, scikit-learn, PyTorch)
- The team has established Python skills
- The project requires complex data processing or ETL pipelines
- Building a backend for predictive analysis or document automation systems
Limits
- Lower performance than Hono and Fastify on pure HTTP throughput (but sufficient for most cases)
- Not suitable for serverless edge deployments (requires a full Python runtime)
- The Python ecosystem for traditional web applications is less mature than the Node.js ecosystem
Direct Comparison
| Criterion | Hono | Fastify | FastAPI |
|---|---|---|---|
| Language | TypeScript/JS | TypeScript/JS | Python |
| Runtime | Edge (Workers, Deno, Bun) | Node.js | ASGI (Uvicorn, Gunicorn) |
| Performance (req/s) | ~100,000+ (edge) | ~50,000 (Node) | ~10,000–20,000 |
| Cold start | < 5ms | N/A (always on) | 500ms–2s |
| Ecosystem | Growing | Mature | Mature (Python) |
| AI/ML Integration | No | Limited | Native |
| Cloudflare Workers Deploy | Native | Non-standard | No |
| Automatic validation | Zod | JSON Schema | Pydantic |
| OpenAPI Documentation | Manual/plugin | Plugin | Automatic |
How We Combine Them at Marfcode
In a typical project with multiple components:
- Frontend (Astro/SvelteKit) on Cloudflare Pages
- Edge API (authentication, routing, lightweight transformations) → Hono on Workers
- Application backend (business logic, integrations) → Fastify on VPS/container
- AI/Data backend (text processing, predictions, automations) → FastAPI on VPS/container
This separation is not always necessary — for many projects, a single Hono or FastAPI API is sufficient. But when the project grows, having components with separate responsibilities pays off in terms of scalability and maintainability.
→ Define the right architecture for your project with Marfcode
Related article: Cloudflare as a deployment platform | Web and Mobile Development for SMEs: complete guide