How we optimized our Akka application using Datadog’s Continuous Profiler
An auxiliary LatencyReportActor running on Akka's default ForkJoinPool-based dispatcher burned 20-30% of a log-processing service's CPU. Its bursty workload woke all 32 threads every second and then parked them again, so time went into ForkJoinPool.scan() and Unsafe.park()/unpark() native calls. Flame graphs and per-thread CPU breakdowns in a continuous profiler traced the cost to the default dispatcher. A one-line config change moving the actor onto the steadily loaded work dispatcher cut CPU by about 30% and shrank the default pool from 32 to 2 threads. The general advice is to watch scan() time (over 10-15% is a red flag) and keep active thread counts stable by limiting actor instances or pool size, consolidating pools, or queueing bursty tasks.
Related posts
- Thundering herd of circuit breakers
Zalando Engineering mediumAdeptA client's circuit breaker stayed open for hours because its half-open probes hit a service that the HPA had scaled down to three pods. The sparse probes succeeded, the breaker closed, and the withheld traffic arrived at once, queued for over 100 ms per request, timed out and re-opened the breaker. Each cycle lasted only about three seconds, too short for CPU-averaged autoscaling to notice. Zalando found the cycle by exporting OpenTelemetry traces as CSV into a bespoke uPlot visualizer that plots hundreds of traces at once. Suggested fixes are autoscaling on queue depth or concurrency, longer or heavier half-open probes, pre-scaling before the breaker closes, load shedding, and propagating cancellations.
- Leveraging Go Worker Pools to Scale Server-side Data Sharing
Shopify Engineering mediumAdeptShopify's Server Pixels service, a Go pipeline that consumes over a billion customer events per day from Kafka, fell behind on consumer lag because it spawned an unbounded number of goroutines to process and produce event batches. Replacing that with a fixed-size worker pool fed by a jobs channel, built on a reusable Worker interface and shut down gracefully with context cancellation and WaitGroups, bounded resource use. Throughput per pod rose from 7.75k to 12.9k events/sec with 15 workers, 19.3k with 50, and 21k after further tuning, a 170% gain. That headroom carried the service through a 46k events/sec peak during BFCM 2021.
- .NET Continuous Profiler: Exception and lock contention
Datadog Engineering hardMasterDatadog's .NET continuous profiler captures thrown exceptions through ICorProfilerCallback::ExceptionThrown and reads each exception's _message field by resolving System.Exception's ClassID from CoreLib metadata and computing the field offset with GetClassLayout. Lock contention durations come from CLR ContentionStart/ContentionStop events, delivered synchronously via EventPipeEventDelivered since .NET 5, with lock owner info added in .NET 8. Both event streams are subsampled with a PID-controller-based adaptive sampler: always at least one exception per type, and contentions bucketed by duration. Sampled values are then upscaled, using a count ratio for exceptions and a duration ratio for locks, since total wait time is what drives latency.
- How we wrote a Python profiler
Datadog Engineering mediumAdeptDatadog built an always-on statistical profiler for Python because deterministic profilers like cProfile can add 2-3x overhead, too much for production. The design borrows from JDK Flight Recorder and splits into recorder, collectors, exporter and scheduler. A Cython-based stack collector samples every thread's stack 100 times per second and lowers its polling rate under heavy load to cap overhead. Memory and lock collectors add allocation and lock-contention data, and profiles are aggregated into compact pprof (protobuf) files uploaded every minute through the Datadog Agent.
- Unbiased Java CPU profiling with JFR in JDK 25
Datadog Engineering mediumAdeptJDK 25 adds an experimental JFR CPU-time sampling event (CPUTimeSample) that gives unbiased CPU profiles without relying on the unsupported HotSpot AsyncGetCallTrace API. The existing ExecutionSample event samples a rotating subset of threads rather than in proportion to CPU time, which can underreport hotspots, notably in reactive workloads. Profilers such as Datadog's therefore combined JFR with SIGPROF-driven AsyncGetCallTrace and vmstructs walking, trading stability for accuracy. After the AsyncGetStackTrace JEP stalled, Oracle, SAP, Amazon and Datadog engineers built on cooperative stack walking, which records lightweight execution points and unwinds only at safepoints. Native frame support and safe on-demand stack capture are next.