How does the underlying request execution pipeline differ in performance between controllers and minimal APIs, and what accounts for the difference?
Short answer
Minimal APIs generally have lower per-request overhead since they bypass much of the MVC framework's action invocation machinery (the filter pipeline resolution, model binding via ModelState, action selection reflection) that controllers go through -- benchmarks typically show…
Advertisement
AModel answer
Minimal APIs generally have lower per-request overhead since they bypass much of the MVC framework's action invocation machinery (the filter pipeline resolution, model binding via ModelState, action selection reflection) that controllers go through -- benchmarks typically show minimal APIs achieving somewhat higher requests-per-second and lower latency for simple endpoints, though for complex endpoints with heavy business logic, the framework overhead difference becomes a smaller fraction of total request time and matters less in practice.
// Minimal APIs: more direct execution path
app.MapGet("/ping", () => "pong"); // minimal framework overhead
// Controllers: more machinery invoked (filters, model binding, action selection)
[HttpGet("ping")]
public IActionResult Ping() => Ok("pong");Real-world example
A high-throughput, latency-sensitive gateway service migrates its simplest pass-through endpoints from controllers to minimal APIs after benchmarking showed a measurable throughput improvement, while keeping complex business-logic-heavy endpoints on controllers where the overhead difference was negligible.
Likely follow-ups
- At what request complexity does the framework overhead difference become negligible?
- What specific MVC pipeline stages does a minimal API bypass?
Related topics