Skip to content

Commit 4e2000e

Browse files
Add startup tuning documentation (#2455)
* Add startup tuning documentation * Update docs/tuning-and-overhead.asciidoc Co-authored-by: eyalkoren <[email protected]> Co-authored-by: eyalkoren <[email protected]>
1 parent fa172d4 commit 4e2000e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/tuning-and-overhead.asciidoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
== Overhead and Performance tuning
33

44
* <<agent-overhead>>
5+
* <<tuning-agent-startup>>
56
* <<tuning-agent>>
67
* <<circuit-breaker>>
78

@@ -68,6 +69,41 @@ The Agent requires some network bandwidth, as it needs to send recorded events t
6869
This is where it's important to know how many requests your application handles and how many of those you want to record and store.
6970
This can be adjusted with the <<tune-sample-rate>>.
7071

72+
[float]
73+
[[tuning-agent-startup]]
74+
=== Tuning the Agent Startup
75+
76+
When the Java agent starts, it needs to initialize various components of the agent, connect
77+
to the APM server, and instrument any already loaded classes that it has been configured to
78+
trace. This takes some time and resources, and if done synchronously on the main thread (which is
79+
the default when using `-javaagent`) will delay the start of the application until complete.
80+
81+
We provide several options to tune the startup, targeted at three startup use cases:
82+
83+
. Immediate synchronous agent start +
84+
The application needs to have instrumentation immediately applied, regardless of startup
85+
time cost - typically because you don't want to miss any traces/transactions right from the
86+
beginning of the application, or some types of actions only happen at initialization and need
87+
to be instrumented before the first instance is created (such as setting up Prepared Statements).
88+
In this use case, use the `-javaagent` command-line flag as per <<setup-javaagent>>
89+
. Fastest start (asynchronously) +
90+
The application can accept instrumentation missing before the application starts
91+
and also accept missing some initial traces and transactions.
92+
In this use case you can attach to the application after startup with <<setup-attach-cli>>
93+
or if you are using the `-javaagent` command-line flag you can start the agent asynchronously
94+
by setting the `elastic.apm.start_async` property (since 1.29.0), eg `java -Delastic.apm.start_async ...`
95+
(you can use `elastic.apm.delay_agent_premain_ms=0` in earlier versions)
96+
. Minimized synchronous start +
97+
The application needs to have instrumentation immediately applied, but needs to minimize the
98+
time before the application starts. This requires some tradeoff: in order to reduce the
99+
synchronous startup time, the number of instrumentations applied needs to be minimized
100+
through the `enable_instrumentations` option.
101+
In this use case you should identify the smallest set of instrumentation groups you can
102+
accept for your application monitoring, and use the `enable_instrumentations` configuration
103+
option detailed in the <<configuration,configuration guide>>. To assist in identifying that
104+
smallest set of instrumentation groups, you can run with logging level set to DEBUG, and
105+
view the statistics produced by the agent on normal termination of the application
106+
71107
[float]
72108
[[tuning-agent]]
73109
=== Tuning the Agent

0 commit comments

Comments
 (0)