Configure tuning threads
Last updated
Last updated
Wildfly use Subsystem configurations. A subsystem is an added set of capabilities added to the core server by an extension. A subsystem provides servlet handling capabilities a sub system provides and EE, EJB, IO etc. A profile is a named list of subsystems, along with the details of each subsystem's configuration EE Subsystem The EE subsystem allows you to configure common functionality in the Java EE platform, such as defining global modules, enabling descriptor-based property replacement, and configuring default bindings. managed executor service context-service The name of the context service to be used by the executor. core-threads The minimum number of threads to be used by the executor. If left undefined the default core-size is calculated based on the number of processors. A value of zero is not advised and in some cases invalid. See the queue-length attribute for details on how this value is used to determine the queuing strategy. hung-task-threshold The runtime, in milliseconds, for tasks to be considered hung by the managed executor service. If value is 0 tasks are never considered hung. jndi-name The JNDI Name to lookup the managed executor service. keepalive-time When the number of threads is greater than the core, this is the maximum time, in milliseconds, that excess idle threads will wait for new tasks before terminating. long-running-tasks Flag which hints the duration of tasks executed by the executor. max-threads The maximum number of threads to be used by the executor. If left undefined the value from core-size will be used. This value is ignored if an unbounded queue is used (only core-threads will be used in that case). queue-length The executors task queue capacity. A length of 0 means direct hand-off and possible rejection will occur. An undefined length (the default), or Integer.MAX_VALUE, indicates that an unbounded queue should be used. All other values specify an exact queue size. If an unbounded queue or direct hand-off is used, a core-threads value greater than zero is required. reject-policy The policy to be applied to aborted tasks. thread-factory The name of the thread factory to be used by the executor. IO Subsystem The IO subsystem allows you to define workers and buffer pools to be used by other subsystems. worker io-threads Specify the number of I/O threads to create for the worker. If not specified, a default will be chosen, which is calculated by cpuCount * 2 stack-size The stack size (in bytes) to attempt to use for worker threads. task-keepalive Specify the number of milliseconds to keep non-core task threads alive. task-max-threads Specify the maximum number of threads for the worker task thread pool.If not set, default value used which is calculated by formula cpuCount * 16 buffer-pool buffer-size The size of each buffer slice in bytes, if not set optimal value is calculated based on available RAM resources in your system. buffers-per-slice How many buffers per slice, if not set optimal value is calculated based on available RAM resources in your system. direct-buffers Does the buffer pool use direct buffers, some platforms don't support direct buffers Processor Core A processor core (or simply “core”) is an individual processor within a CPU. Many computers today have multi-core processors, meaning the CPU contains more than one core.
For many years, computer CPUs only had a single core. In the early 2000s, as processor clock speeds began plateauing, CPU manufacturers needed to find other ways to increase processing performance. Initially, they achieved this by putting multiple processors in high-end computers. While this was effective, it added significant cost to the computers and the multiprocessing performance was limited by the bus speed between the CPUs. By combining processors on a single chip, CPU manufactures were able to increase performance more efficiently at a lower cost. The individual processing units became known as “cores” rather than processors. In the mid-2000s, dual-core and quad-core CPUs began replacing multi-processor configurations. While initially only high-end computers contained multiple cores, today nearly all PCs have multi-core processors.
NOTE: “Core” is also the name of Intel’s processor line, which replaced the Pentium lineup in 2006. Examples of Intel Core processors include the Core Duo, Core 2, Core i3, Core i5, and Core i7.
Thread The threads of a computer program allow the program to execute sequential actions or many actions at once. Each thread in a program identifies a process that runs when the program asks it to. Threads are typically given a certain priority, meaning some threads take precedence over others. Once the CPU is finished processing one thread, it can run the next thread waiting in line. However, it's not like the thread has to wait in line at the checkout counter at Target the Saturday before Christmas. Threads seldom have to wait more than a few milliseconds before they run. Computer programs that implement "multi-threading" can execute multiple threads at once. Most modern operating systems support multi-threading at the system level, meaning when one program tries to take up all your CPU resources, you can still switch to other programs and force the CPU-hogging program to share the processor a little bit. The term "thread" can also refer to a series of related postings in an online discussion. Web-based bulletin boards are made up of many topics, or threads. The replies posted in response to the original posting are all part of the same thread. In e-mail, a thread can refer to a series of replies back and forth pertaining a certain message. JVM Options there are three types of options that you can include to your JVM, standard, non-standard, and advanced options. If you try an advanced option, you always use the option with -XX . Similarly, if you’re applying a non-standard option, you use -X . Standard options don’t prepend anything to the option. Java heap size
-Xms - set initial Java heap size -Xmx - set maximum Java heap size -Xss - set java thread stack size
Xms – This option is to define starting heap size for JVM, e.g.,Xms2048m which means an initial heap size of JVM is 2 GB around. So, when a JVM starts, the heap memory will be this much big. Surprisingly yes! This is carried to prevent resizing during startup and enhance the startup time of JVM. Xmx – This option is to define the maximum heap size of JVM, e.g.,Xmx2048m which means the maximum heap size of JVM will be 2 GB only. You will essentially always have-Xms and -Xmx together. PermGen Size Earlier JVM options define the size of heap memory but -XX:PermSize is to define the size of PermGen space, where the string pool and class metadata is saved. This option is particularly effective for a web server like Tomcat, which often loads classes of the web application during deployment. By the way, It’s worth realizing that PermGen space is taken over by Metaspace in Java 8, and this option is not applicable if you are running with JRE 8 JVM. Handling ‘OutOfMemory’ Error To trigger heap dump on out of memory, you can use -XX:+HeapDumpOnOutOfMemoryError This JVM option produces a stack dump when your JVM dies with OutOfMemory Error. There is no expense involved unless an OOM really occurs. This flag is a requisite for production systems as it is usually the only way to determine the problem deeply.
The heap dump will be set up in the “current directory” of the JVM by default. If you wish to create heap dumps on specific directory, then run
-XX:HeapDumpPath= [path-to-heap-dump-directory] -XX:+UseGCOverheadLimit -XX:OnOutOfMemoryError="< cmd args >;< cmd args >"
The heap dump file can be huge in size, up to gigabytes, so assure that the target file system allows sufficient capacity. If we want to restart the server immediately after out of memory occur, then we can set this parameter of the same purpose –XX:OnOutOfMemoryError="shutdown -r" Trace class loading and unloading -XX:+TraceClassLoading and -XX:+TraceClassUnloading are two JVM options that we use to print logging information whenever classes loads into JVM or unload from JVM. These JVM flags are useful if you have any type of memory leakage linked to classloader and suspecting to it that classes are not unloading or garbage collected.
Recommended Standard Configure for ONEWEB: