Performance tuning
editPerformance tuning
editThere are many options available to tune agent performance. Which option to adjust depends on whether you are optimizing for speed, memory usage, bandwidth or storage.
Sampling
editThe first knob to reach for when tuning the performance of the agent is TransactionSampleRate
.
Adjusting the sample rate controls what percent of requests are traced.
By default, the sample rate is set at 1.0
, meaning all requests are traced.
The sample rate will impact all four performance categories, so simply turning down the sample rate is an easy way to improve performance.
Here’s an example of setting the sample rate to 20% using Configuration on ASP.NET Core:
{ "ElasticApm": { "TransactionSampleRate": 0.2 } }
Stack traces
editIn a complex application, a request may produce many spans. Capturing a stack trace for every span can result in significant memory usage. Stack traces are also captured for every error. There are several settings to adjust how stack traces are captured.
Disable capturing stack traces
editTo disable capturing stack traces (for both spans and errors),
set StackTraceLimit
to 0
.
Capture stack traces only for long running spans
editIn its default settings,
the APM agent collects a stack trace for every recorded span with duration longer than 5ms.
To increase the duration threshold,
set SpanStackTraceMinDuration
.
Reduce number of captured stack trace frames
editThe StackTraceLimit
controls how many stack frames should be collected
when a capturing stack trace.
Disable capturing HTTP request and response headers
editCapturing HTTP request and response headers increases memory allocations,
network bandwidth and disk space used by Elasticsearch.
To disable capturing HTTP request and response headers,
set CaptureHeaders
to false
.
Increase metrics collection interval
editThe .NET agent tracks certain system and application metrics.
These metrics are regularly collected and sent to the APM Server and from there to Elasticsearch.
You can adjust the interval for metrics collection with the setting MetricsInterval
.