ETS vs Redis · Anantha Kumaran

submited by
Style Pass
2024-10-26 07:30:03

I recently made some optimizations at work that saved more than 40% CPU at peak time. In this post, I go over the details about how I identified and fixed the bottleneck.

The first step is to identify the bottleneck. There might or might not be a single big bottleneck in a system. Usually, it’s not straightforward to replicate the production workload on a staging or developer machine. Instead, I focused on profiling the system in production without disrupting live workloads.

Erlang provides a range of tools to find memory or CPU bottlenecks. However, most of them are only suitable to run on a developer machine because of the performance overhead. Erlang also provides support for a Linux profiler called perf. I added +JPperf true to the rel/vm.args.eex file to enable perf support.

Let’s break down the steps. The first command perf record collects data, and the second command just reformats the collected data. -F controls the sampling frequency; the default is usually set to 1000, but I typically reduce this to 99 on a production system to reduce the profiling overhead.

Leave a Comment