|
2 | 2 | == Overhead and Performance tuning |
3 | 3 |
|
4 | 4 | * <<agent-overhead>> |
| 5 | +* <<tuning-agent-startup>> |
5 | 6 | * <<tuning-agent>> |
6 | 7 | * <<circuit-breaker>> |
7 | 8 |
|
@@ -68,6 +69,41 @@ The Agent requires some network bandwidth, as it needs to send recorded events t |
68 | 69 | 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. |
69 | 70 | This can be adjusted with the <<tune-sample-rate>>. |
70 | 71 |
|
| 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 | + |
71 | 107 | [float] |
72 | 108 | [[tuning-agent]] |
73 | 109 | === Tuning the Agent |
|
0 commit comments