|
| 1 | +/////////////////////////////////////////////////////////////////////////////// |
| 2 | + |
| 3 | + Copyright (c) 2022 Oracle and/or its affiliates. |
| 4 | + |
| 5 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + you may not use this file except in compliance with the License. |
| 7 | + You may obtain a copy of the License at |
| 8 | + |
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + |
| 11 | + Unless required by applicable law or agreed to in writing, software |
| 12 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + See the License for the specific language governing permissions and |
| 15 | + limitations under the License. |
| 16 | + |
| 17 | +/////////////////////////////////////////////////////////////////////////////// |
| 18 | +
|
| 19 | += Performance Tuning |
| 20 | +:h1Prefix: MP |
| 21 | +:description: Helidon MP Performance Tuning |
| 22 | +:feature-name: Performance Tuning |
| 23 | +:microprofile-bundle: true |
| 24 | += :keywords: helidon, microprofile, micro-profile, performance, tuning |
| 25 | +
|
| 26 | +
|
| 27 | +In this guide you fill find basic advice for performance tuning of your Helidon application. Most of them target Netty tuning, as Helidon is based on it. |
| 28 | +You should also consider configuring/tuning Java heap size as per any Java application. |
| 29 | +
|
| 30 | +
|
| 31 | +== Use `io.helidon.microprofile.bundles:helidon-microprofile-core` |
| 32 | +
|
| 33 | +Use `helidon-microprofile-core` dependency (and not the `helidon-microprofile` dependency) and add only what you use. For example: |
| 34 | +
|
| 35 | +[source,xml] |
| 36 | +---- |
| 37 | +<dependency> |
| 38 | + <groupId>io.helidon.microprofile.bundles</groupId> |
| 39 | + <artifactId>helidon-microprofile-core</artifactId> |
| 40 | +</dependency> |
| 41 | +<dependency> |
| 42 | + <groupId>io.helidon.microprofile.metrics</groupId> |
| 43 | + <artifactId>helidon-microprofile-metrics</artifactId> |
| 44 | +</dependency> |
| 45 | +<dependency> |
| 46 | + <groupId>io.helidon.microprofile.health</groupId> |
| 47 | + <artifactId>helidon-microprofile-health</artifactId> |
| 48 | +</dependency> |
| 49 | +<dependency> |
| 50 | + <groupId>io.helidon.media</groupId> |
| 51 | + <artifactId>helidon-media-jsonp</artifactId> |
| 52 | +</dependency> |
| 53 | +---- |
| 54 | +
|
| 55 | +
|
| 56 | +== Configure Netty worker thread pool size |
| 57 | +
|
| 58 | +The Netty worker thread-pool is what handles your incoming requests. It defaults to 2*NCPU. To set it to something else you can set this property in `microprofile-config.properties`: |
| 59 | +
|
| 60 | +[source,properties] |
| 61 | +---- |
| 62 | +server.worker-count=4 |
| 63 | +---- |
| 64 | +
|
| 65 | +
|
| 66 | +=== Configure Helidon server pool size |
| 67 | +
|
| 68 | +The Helidon server thread-pool takes requests from Netty and invokes your JAX-RS endpoints. You can control lts configuration in `microprofile-config.properties`. This is Helidon MP specific only. |
| 69 | +
|
| 70 | +[source,properties] |
| 71 | +---- |
| 72 | +server.executor-service.core-pool-size: 2 |
| 73 | +server.executor-service.max-pool-size: 4 |
| 74 | +---- |
| 75 | +
|
| 76 | +To verify settings increase the log level for Helidon's executor service by adding this to your `logging.properties`: |
| 77 | +
|
| 78 | +[source,properties] |
| 79 | +---- |
| 80 | +io.helidon.common.configurable.ThreadPool.level=FINE |
| 81 | +---- |
| 82 | +
|
| 83 | +
|
| 84 | +=== Configure Netty's maxOrder (Helidon 2.4.1 or earlier) |
| 85 | +
|
| 86 | +In some situations Netty can aggressively allocate memory per request. This has been addressed in recent versions of Helidon and Netty, but if you are running an earlier version set this system property when you start your Helidon application: |
| 87 | +
|
| 88 | +``` |
| 89 | +-Dio.netty.allocator.maxOrder=6 |
| 90 | +``` |
| 91 | +
|
| 92 | +You can try smaller numbers. |
0 commit comments