JVM Tuning Summary (11)-Reflection

Source: Internet
Author: User
Tags file system garbage collection reflection

The paradox of garbage collection

The so-called "Chengye defeated Xiao". Java garbage collection does bring a lot of benefits and facilitates development. However, in some high-performance, high concurrency, garbage collection has become a bottleneck in Java application constraints. At present, the JDK garbage collection algorithm, always can not solve the garbage collection when the pause problem, because this pause seriously affected the program's corresponding time, causing congestion or accumulation. This is also an important reason for subsequent JDK additions to the G1 algorithm.

Of course, the above is from a technical point of view to solve the problem of garbage collection, but from the system design aspects we need to ask:

Do we need to allocate such large memory space to the application?

Can we design our system by effectively using memory rather than by expanding memory?

What we have in our memory.

What do I need to put in memory? Personally, the need to put in memory is what your application needs to be used again in the near future. Think about it, if you don't use these things in the future, why put it in memory? Is it better to put files and databases? These things generally include:

1. System Run-time Business-related data. For example, session of Web application, session of instant message and so on. These data typically need to exist during a user access cycle or in a usage process.

2. Caching. The cache is much more, you want to quickly access can be put in here. In fact, the above business data can also be interpreted as a cache.

3. Threads.

Therefore, we can not think that if we do not put business data and caching in the JVM, or to separate them out, then the Java application will need to use the memory would be greatly reduced, and garbage collection time will be reduced accordingly.

I think it's possible.

The way to solve it

Database, File system

Putting all the data into a database or file system is the easiest way to do it. In this way, the Java application memory is essentially equal to the memory required to process a peak concurrent request. The acquisition of data is obtained from the database and file system on each request. It can also be understood that after a business visit, all objects can be recycled.

This is one of the most efficient ways to use memory, but it is inefficient from an application perspective.

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.