The difference between the server mode and the client mode in JVM of Java virtual machine, jvmclient

Source: Internet
Author: User

The difference between the server mode and the client mode in JVM of Java virtual machine, jvmclient

Differences between JVM client mode and Server Mode

The main difference between JVM Server mode and client mode is that-Server mode starts slowly, but the performance will be greatly improved once it starts up.

JVM can greatly improve performance in Server mode. In Server mode, the application startup speed is about 10% slower than that in client mode, but the running speed is at least 10 times faster than that in Client VM.

When the run mode parameter is not specified, the VM starts to check whether the host is a Server. If yes, the VM starts in Server mode. Otherwise, the VM starts in client mode, j2SE5.0 detects a minimum of 2 CPUs and 2 GB memory.

Because the CPU, memory, and hard disk of the server are more powerful than those of the client machine, after the program is deployed, it should be started in server mode to obtain better performance;
The default value of JVM in client mode is-Xms is 1 M,-Xmx is 64 M, JVM is 128 M by default in Server mode, and-Xmx is 1024 M;
Server: Slow startup and complete compilation. the compiler is an adaptive compiler with high efficiency. It is designed to optimize server applications and maximize program execution speed in the server environment.
Client: Quick Start, with low memory usage and fast compilation. It is optimized for desktop applications and optimized to reduce startup time in the client environment;

It is applicable to the client mode when JVM is used to start interactive applications on the GUI. It is recommended to use the Server mode when JVM is used to run the Server background program.

Run java-version to check the default mode in which jvm works.

 

GCC in Figure 1

In clien mode, the new generation selects serial gc and the old generation selects serial gc.
In server mode, the new generation selects parallel gc recovery, and the old generation selects parallel gc.
Generally, there are two ways to choose system applications: throughput first and pause time first. The server default parallel gc mode is used for throughput first, and the concurrent gc (CMS) mode is used for pause time first.

Other extended knowledge points

JDK has two types of VMS, VM clients, and VM server applications. These two solutions share the hotspot code library of the java Runtime Environment, but use different compilers for unique performance characteristics of clients and servers, including compiling inline policies and stack default values.

Although the server is similar to the client virtual machine, the server virtual machine has adjusted the maximum peak operation speed. It is intended for server applications that run for a long time. It requires the fastest running speed to exceed the memory usage of a Quick Start time or a small runtime.

The customer's VM compiler is a classic virtual machine and a real-time update (JIT) compiler used by previous JDK versions. The client virtual machine provides improved performance for running applications and applets. Hotspot customers of Java virtual machines have reduced the startup time and memory usage of their applications, making them particularly suitable for their environments. In general, the client system provides a better GUI.

Therefore, the real difference lies at the compiler level:

The client Virtual Machine compiler does not attempt to execute more complex optimizations executed by the compiler on the server virtual machine. However, during the switching process, it takes less time to analyze and compile a piece of code. This means that the client virtual machine can be started faster and requires a small memory usage.

The server virtual machine contains an advanced adaptive compiler that supports Optimization of many C ++ compilers, the same type, and some optimizations, which cannot be completed by a traditional compiler, for example, a positive inline is called in a virtual method. This is a competitive and performance advantage, static compiler. Adaptive Optimization Technology is flexible in its methods, and is generally superior to or even advanced static analysis and compilation technologies.

-The Server mode is slow to start, but the performance will be greatly improved after it is run, because: When the virtual machine is in-Client mode, A lightweight compiler codenamed C1 is used, while the-Server Mode-started virtual machine uses a relatively heavyweight code C2 compiler. C2 is more thorough than the C1 compiler, high performance.

Generally, you only need to change the order of the two configurations-server KNOWN and-client KNOWN. The premise is that both the server and client folders exist in the JAVA_HOME/jre/bin directory, corresponding to their respective JVMs.

The following is a sentence:

In JVM Server mode, the application starts slowly but runs fast. In JVM Client mode, the application starts fast but runs slowly.

Recommendation: run on the Server in Server mode, and run in Client mode in Client or GUI mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.