Moving a Symfony app to Rust one route at a time (with honest numbers)
Oxidize 0.1.0 — experimental, open source (MIT/Apache-2.0) Rewriting a PHP application in Rust is a big-bang project, and big-bang rewrites rarely ship. But most Symfony apps don't need a rewrite: they have a handful of hot or heavy paths — a report that crunches 200k rows, an XLSX export that eats 350 MB, an endpoint that gets hammered — and a lot of code that is fine as it is. Oxidize lets you…
Rewriting a Symfony application in Rust can be a large-scale project, but it's not necessary for most apps. Focus on the few performance-critical paths, such as generating reports, exporting CSV files, or handling heavy traffic endpoints. Oxidize allows you to gradually migrate these specific paths to Rust while keeping the rest of your application intact, using the strangler pattern.
There are three modes for this migration: Mode A involves adding a PHP extension and a bundle to your existing Symfony app, enabling you to call Rust code as routes, services, Messenger handlers, listeners, or console commands. Mode B introduces a native Rust server that handles Rust routes directly while still allowing PHP to handle other routes. Mode C combines the best of both previous modes, with a Rust server handling Rust routes and proxying the rest to PHP-fpm or PHP embedded in-process.
In the case study presented, the authors used Oxidize to port four endpoints from a Symfony Demo application to Rust. They measured the performance of these endpoints under different modes and found that Rust offered significant speed improvements in certain scenarios, such as a Rust server handling RSS feed requests and a native Rust server reading from Doctrine.
However, the benefits were more noticeable in mode B, where the Rust server handled Rust routes directly and PHP handled other routes. In some cases, such as rendering a Twig page, Rust did not provide a significant performance gain, as the rendering remained in PHP.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to