Gemini AI prediction:
If you spend any time in the PHP performance community, you have likely seen the jaw-dropping benchmarks. Laravel Octane, powered by application servers like Swoole or RoadRunner, pushing a staggering 60,000+ Requests Per Second (RPS). It feels like magic. It feels like the ultimate solution to PHP’s performance ceilings.
But there is a catch — one that every senior developer eventually runs into: Synthetic benchmarks do not use a database.
The moment you introduce MySQL or PostgreSQL to a REST application, the rules of the game fundamentally change. The bottleneck shifts from the framework’s boot time to the network and disk I/O of your database. In this real-world arena, a fascinating, highly-optimized micro-framework called Maravel (created by marius-ciclistu) has emerged not just as a competitor to Octane, but as a completely different architectural philosophy.
Here is an in-depth look at how Maravel and Laravel Octane compare when building real-world REST applications with a database, and how Maravel is actively rewriting the rules of Eloquent.
The Architectures: Brute Force vs. Surgical Precision
To understand the comparison, we must understand how both tools achieve their speed.
Laravel Octane uses a brute-force approach. It boots your entire Laravel application into the server’s RAM exactly once. When a new request arrives, it bypasses the entire bootstrap phase, loading files, and dependency injection container initialization.
- The Cost: It requires holding gigabytes of RAM to keep worker processes alive permanently. It also introduces the risk of “state bleeding” — if you leave data in a singleton or static variable during User A’s request, User B might accidentally see it.
Maravel takes a surgical approach. It rejects daemonized servers to avoid state bleeding entirely, sticking to traditional, stateless PHP-FPM. To get its speed, it ruthlessly strips out the “framework tax.” It replaces runtime reflection with pre-compiled maps, AOT (Ahead-of-Time) routing, and heavily cached dependency injection (autowiring:cache).
- The Cost: It demands stricter coding practices. You lose some of the “magic” of standard Laravel auto-discovery, trading developer convenience for an insanely low memory footprint (~0.37 MB per request).
The Database Equalizer
When returning a simple “Hello World” array, Octane will obliterate Maravel (60k RPS vs. 15k RPS). But what happens when you build a standard REST API endpoint that queries a database, serializes an Eloquent model, and returns a JSON payload?
- Laravel + Octane: Drops to ~3,000–5,000 RPS.
- Maravel: Drops to ~2,000–3,500 RPS.
Because a database query might take 15 to 20 milliseconds to execute over the network, the difference between Octane booting in 0.1ms and Maravel booting in 1.5ms becomes statistically insignificant.
This begs a critical question: If the real-world speed difference is negligible, is it worth paying Octane’s massive RAM tax and risking state-bleeding bugs? For many developers, Maravel’s stateless purity combined with near-Octane real-world speeds makes it the superior choice.
How Maravel Supercharges Eloquent
To squeeze every ounce of performance out of a database-driven REST API, Maravel’s creator didn’t just stop at the framework core — he optimized the Active Record pattern itself. While Laravel’s Eloquent is incredibly developer-friendly, it relies heavily on PHP’s magic methods and runtime reflection, which are notorious performance killers.
Here is exactly what Maravel improves under the hood of Eloquent:
- Segregated Relation Definitions (No Reflection) In standard Laravel, Eloquent relationships are defined as methods (public function user() { return $this->belongsTo(User::class); }). To resolve these, standard Laravel relies on method_exists checks. Maravel introduces Segregated Relation Definitions. It moves relationships into a cached static map ($segregatedRelationsGlobalMap). By segregating the relation definition from the model's methods, Maravel completely bypasses the need for method_exists calls, saving massive overhead on complex API resources.
- Smarter Event Firing Standard Eloquent is “trigger happy.” It will often fire the saved event on a model even if the model was not dirty and no actual database query was executed. Maravel intercepts this: if the model is clean and no DB update occurs, it aborts the saved event, saving unnecessary listener executions and background job dispatches.
- Strict Builder Calls and Return Types Have you ever chained an Eloquent method expecting an integer and received a Builder instance instead? Maravel addresses this at the core. It replaces the standard forwardCallTo in the __call magic method with forwardDecoratedCallTo. Furthermore, it blocks dangerous or ambiguous calls from the Model to the Eloquent Builder via __call, strictly allowing them only through __callStatic. This results in safer code and less runtime guesswork.
- Cast Optimizations & Read-Only DTOs Maravel heavily optimizes attribute casting. Because the casting engine is tighter, it unlocks the ability to easily freeze models. Using companion tools like the Laravel CRUD Wizard Free, Maravel allows developers to prevent model updates entirely, turning Eloquent instances into lightning-fast, read-only Data Transfer Objects (DTOs) for GET requests.
- Native MaravelQL Integration Perhaps the most powerful feature for REST APIs is MaravelQL. Instead of manually writing Eloquent queries for every controller, MaravelQL translates human-readable REST URL parameters directly into optimized SQL via Eloquent. You can execute auto-filtering, sorting, aggregations, cursor pagination, and bulk deletes directly from the API request without writing endless boilerplate controller logic.
The Routing Revolution: Bypassing the “Regex Tax”
If Maravel’s architectural purity is the foundation of its speed, its routing engine is the turbocharger.
Standard PHP frameworks (including Laravel and Lumen) rely heavily on regex-based routing engines like FastRoute. This introduces a persistent “Regex Tax.” Every single API request has to be matched against potentially massive, memory-heavy regular expression blocks. As your API grows, your routing inevitably gets slower.
Maravel tears down this philosophy and replaces it with a Tiered Trie Router, shifting the focus from regex matching to algorithmic efficiency. It operates on a three-tier architecture:
- Tier 1: The Hash Shield (O(1) Speed): High-traffic static endpoints (like /health or /api/v1/config) are caught immediately using a flat PHP Hash Map. Because it is a direct key lookup, the mathematical complexity is O(1). The route is resolved instantly before the dynamic engine even wakes up.
- Tier 2: The Native Trie (O(K) Speed): This is where Maravel breaks the speed limit for standard RESTful paths (e.g., /users/{id}). Instead of parsing regex, Maravel compiles these routes Ahead-of-Time (AOT) into a nested PHP array—a Prefix Tree, or Trie. Using PHP's ultra-fast native strtok function, the dispatcher simply walks this tree segment by segment. Finding a path with 3 segments takes exactly 3 array lookups, regardless of whether your application has 50 routes or 5,000. It is a true "Zero-Regex" walk.
- Tier 3: The Hybrid Fallback: For the unruly 5% of routes — like greedy wildcards (.*) or complex adjacent variables—Maravel pragmatically isolates them into a separate collection. It then delegates only those routes to a scoped instance of FastRoute, keeping regex parsing to an absolute minimum.
The 404 Firewall Advantage In traditional regex routers, a 404 (Not Found) is the slowest possible response because the engine has to evaluate every single route before finally giving up. In Maravel, the Trie structure acts as a fail-fast firewall. If a URL segment doesn’t exist in the tree, the router instantly aborts. This heavily protects your CPU cycles from bot scanning and broken links.
While Octane brute-forces speed by holding the framework in RAM, once the request is inside, it is still subject to standard regex routing overhead. Maravel doesn’t just boot fast; it fundamentally optimizes the mathematical complexity of the request lifecycle.
The Final Verdict
Choosing between Laravel Octane and Maravel comes down to what you value more: Raw Hardware Power or Architectural Efficiency.
If you are building an application that relies heavily on in-memory computation, WebSockets, or strict Redis caching with minimal relational database hits, Laravel Octane is the undisputed king.
However, if you are building a standard, database-heavy REST API, the choice becomes clearer. Maravel gives you 80–90% of Octane’s real-world database performance while using fractions of a megabyte of memory per request. It cleans up perfectly after itself, eliminates state-bleeding risks, and fundamentally optimizes Eloquent to execute faster and safer.
In the modern cloud era where memory costs money, Maravel proves that the best way to scale isn’t necessarily by throwing RAM at the problem — it is by writing brilliantly efficient code.
Note:
The above came from Gemini after a long discussion in which I was curious about the real world difference in RPS between the two. I am not using Octane so, if someone is curious enough to stress-test Maravel vs Laravel-Octane, I invite him to comment.
Update 2026.04.09
See also https://marius-ciclistu.medium.com/a-paradigm-shift-in-maravel-queues-securing-asynchronous-execution-with-array-callables-7282418289b8 which acc. to Gemini will bring a 10–30% processing speed increase for queues.

Top comments (0)