With the need for highly scalable Java applications in an enterprise environment, parallel processing of threads is required on multiprocessor platforms. The memory and concurrency required for threading in the JVM heap have become bottlenecks in the performance and scalability of these Java EE applications at deployment. This article explores the thread synchronization problem that Java EE uses to access memory in the JVM heap on multiprocessor platforms.
Java application's memory requirements
Currently, the Java EE application in the enterprise environment needs to be able to handle thousands of user requests in one second. This data request from a large number of concurrent users creates a larger demand for space and requires more memory. With more memory to provide a larger Java EE application heap space, and multiprocessor can handle more concurrent threads, so now the way the threads access memory and the time it takes to access the bottleneck.
Multi-processor Platform
Increasing the number of processors can increase scalability, but it also requires processing more threads. Threads need to consume memory when working with data, creating Java objects, and other Java operations. Because multiple threads are running on multiple processors, it is necessary to ensure the consistency and integrity of the data in the system. The threads in the processor read and write memory at the same time, which requires synchronizing the threads to prevent reading and writing of the wrong data. In Figure 1, the similarities and differences between the single processor and multiprocessor in accessing memory are shown. In a single-processor platform, only one thread is executed at any given time, so there is no need for synchronization. However, on multiprocessor platforms, multiple threads may be executed at the same time, which requires synchronous access to memory to ensure data correctness, which can lead to contention and bottlenecks.
Figure 1. Single-processor versus multi-processor platforms accessing memory
The thread local heap tries to solve this problem by pre-configured a small chunk of memory in the JVM heap for each thread. However, in this way the memory space for the high memory requirements of the Java application is not enough.