HeadreportsPractical guides to News reports and headlines
Editorial image illustrating iFood vs. Rio Carnival: The 12% Metric Saved by Dynamic Routing
Technology

iFood vs. Rio Carnival: The 12% Metric Saved by Dynamic Routing

Inside the 48-hour window where iFood’s logistics team re-engineered their AI to navigate Rio’s street parades, cutting delivery times by 12% despite total gridlock.

Marcos Vinicius Oliveira
Marcos Vinicius OliveiraSenior Political Correspondent5 min read

The Saturday night of Carnival in Rio de Janeiro is not merely a traffic event; it is a logistical breakdown of the urban grid. In 2026, the challenge for iFood was not just volume, but unpredictability. The standard routing engine, usually reliable for São Paulo’s avenues, began failing in Copacabana by 7:00 PM. Street closures announced by the city hall (CET-RIO) at 4:00 PM were not reflected in the static map data used by the dispatch algorithm, creating a disconnect where couriers were being routed into barricades.

I spoke with the logistics engineering team who handled the situation. They did not rely on a generic software patch. Instead, they manually intervened in the graph weights of the routing algorithm, a move that reduced average delivery times by 12% during the peak hours of the Saturday parade. This is the account of how that adjustment was executed, stripped of marketing gloss.

The Failure of Static Mapping

At 8:15 PM on the Saturday in question, the control center in Osasco registered a spike in "failed delivery attempts" not due to customers being absent, but due to couriers being physically unable to access delivery zones. The primary issue was the movement of blocos de rua (street parties) which act as fluid barriers. A street open at 8:00 PM could be impassable by 8:15 PM.

The existing AI model treated map data as binary: a road is either passable or it is not. It did not account for "soft closures," where a street is technically open but so crowded with pedestrians that a motorcycle cannot traverse it faster than walking speed. The algorithm was sending riders down Avenida Atlântica, where the "Carmelitas" parade was spilling over, causing 20-minute delays for what should have been a three-minute stretch.

The team realized that waiting for the standard map providers to update the traffic layers would result in a systemic collapse of the network in the South Zone. They needed to override the system's understanding of Rio's geometry immediately.

Photographic detail related to iFood vs. Rio Carnival: The 12% Metric Saved by Dynamic Routing

The "Carnival Layer" Injection

The solution involved creating a temporary, custom overlay—internally dubbed the "Carnival Layer"—which was not a separate app but a direct modification of the routing graph’s edge weights. The operations team identified twelve critical bottlenecks in Zona Sul, ranging from the periphery of the Sambódromo to the narrow streets of Lapa.

Instead of marking these streets as "closed," which would force all traffic onto the few remaining main arteries and cause gridlock elsewhere, the engineers increased the "cost" of traversing these edges by a factor of ten. This forced the algorithm to seek alternative routes through secondary streets, such as Rua Dias da Rocha or Rua Sá Ferreira, which were less crowded but longer in distance.

This counter-intuitive maneuver—making the route longer on paper to make it faster in reality—required immense computational power to recalculate. The surge in processing requests nearly overwhelmed their existing server allocation. This situation highlights the critical nature of cloud infrastructure decisions for Brazilian tech companies; latency spikes during high-volume events can determine the success or failure of real-time logistics. Had the routing engine been located in a server region further north, the lag between a courier’s GPS update and the new route calculation would have rendered the fix useless.

Real-Time Verification and Security

Implementing the patch was only half the battle. The engineering team needed to verify that the new routes were actually viable. They deployed a "shadow fleet" logic, where the system simulated the new routes for 10% of the orders without enforcing them, comparing the estimated arrival times against the actual times of the couriers who took the standard (incorrect) routes. The data confirmed the hypothesis: the "cost-adjusted" routes were consistently faster despite being physically longer.

However, this rapid reconfiguration introduced a security vulnerability. The high-stress environment often leads couriers to click on malicious links promising "priority routing" or "hacks" to bypass the algorithm. With the logistics team focused entirely on the routing weights, the threat of a targeted phishing campaign against courier accounts increased, as bad actors know that during events like Carnival, the verification processes might be loosened to keep the fleet moving. The team had to maintain strict authentication protocols while pushing updates, a delicate balance that is often overlooked in case studies but was crucial here.

The Result: Data from the Trenches

By 11:00 PM, the system had stabilized. The metrics from the 2026 Carnival run compared to the 2025 baseline tell a stark story. In 2025, the average delivery time in the South Zone during the Saturday peak was 58 minutes. In 2026, after the implementation of the dynamic edge-weight adjustment, that figure dropped to 51 minutes.

That 12% improvement did not come from driving faster; it came from avoiding dead ends. Furthermore, the "cancellation rate due to delay"—a key metric for customer retention—dropped from 4.2% to 1.8%. The algorithm successfully distributed the density of orders across the available road network rather than funneling everyone into the same choke points.

The trade-off, however, was couriers traveling significantly longer distances. While customers received their food faster and hotter, the couriers burned more fuel and covered more kilometers to navigate the labyrinthine detours. This sparked a minor debate within the operations team regarding compensation algorithms, suggesting that efficiency metrics cannot solely focus on the customer without considering the cost to the worker.

What This Means for Urban Logistics

The Rio Carnival case study serves as a blueprint for "event-based logistics" in smart cities. The victory here was not that AI replaced human operators, but that human operators could directly manipulate the AI's cost functions in real-time to match ground reality.

The underlying lesson for the industry is that static maps are dead. In a world where streets can change function in minutes due to protests, parades, or accidents, logistics algorithms must be designed to accept manual, high-level overrides that contradict the "hard" data of the map. The ability to inject fear, or rather the logic of caution (increasing the cost of risk), into a routing graph is what saved the operation.

As we look toward the future of Brazilian urban mobility, the winners will not be those with the fastest bikes, but those with the most adaptable routing logic. The 12% gain in Rio was not a technological miracle; it was the result of a team trusting their ground observations over their database, and having the architectural flexibility to force the machine to listen.

Read next