Mercado Libre Diego Parra Oct 9, 2024

Tales of Performance Engineering

Article Summary

Diego Parra from Mercado Libre's Performance Engineering team just shared how they slashed API response times by 60% with one strategic fix. The culprit? Regex compilations eating 40% of CPU cycles.

Mercado Libre introduced their new Performance Engineering team and detailed a real-world optimization of a critical payments API. Using continuous profiling and flame graphs, they identified that repeated regex compilations were crushing performance and memory allocation.

Key Takeaways

Critical Insight

A simple caching strategy for compiled regex patterns delivered massive gains: 60% faster responses, 98% fewer errors, and 60% fewer instances needed.

The team hints that profiling data combined with AI could unlock even more optimization patterns across their platform.

About This Article

Problem

A Go API in Mercado Libre's payments platform was using too much CPU and memory. Garbage collection was eating up 11.2% of CPU cycles because of how the code allocated memory.

Solution

Diego Parra's Performance Engineering team started caching regex patterns with Go's ccache library. This stopped the code from compiling the same patterns over and over, which had been taking 40% of CPU and 73% of memory allocations.

Impact

Response times dropped from 231.94ms to 76.52ms at the high end. Garbage collection CPU usage fell from 11.2% to 6.7%, which is about a 40% improvement in how efficiently the garbage collector runs.