Memory and CPU allocation
RAM and JVM memory
Magnolia is a Java application running in a JVM that consumes memory. You should configure and control the memory used by the JVM. This section describes configuring both RAM (Random Access Memory) and JVM (Java Virtual Machine) heap settings to increase performance in your Magnolia instances.
RAM and heap memory are related but distinct concepts in computer systems. RAM is a computer’s overall physical memory, while heap memory is a specific portion of RAM used by Java programs for dynamic memory allocation.
Minimum RAM requirements
The RAM (Random Access Memory) required for Magnolia depends on many different factors such as the size of your uploads and the images you manipulate, the number of editors, the number of concurrent users on your public instance, if they use sessions or not, and so on.
However, Magnolia suggests you consider the following minimum guidelines:
-
Local development:
3 GB
-
Production environment
-
Author:
4 - 12 GB
-
Public:
4 - 10 GB
-
Optimizing heap size
A JVM running Magnolia may run other applications simultaneously. All JVM applications use heap memory. You can adjust the heap memory settings based on the RAM available to optimize the performance of your instances.
-
The (on) heap memory is the place in memory for the dynamically allocated objects of your running project.
-
The off-heap memory is where the JVM is used for the garbage collection claim, among other tasks, including all the serialized objects.
Magnolia can use off-heap memory for:
-
Imaging operations (resizing, cropping, other image manipulation)
-
Compressing or decompressing files
-
Publishing, especially when publishing large digital assets or doing recursive publications
-
-
When the stack memory reaches capacity, the Java runtime triggers a
java.lang.StackOverflowError
, while ajava.lang.OutOfMemoryError: Java Heap Space
error occurs when the heap memory is exhausted.To resolve the
OutOfMemoryError
, you can include the JVM parameterXX:MaxRAMPercentage=60
to set the maximum heap as a percentage of total RAM.
-
To specify both the initial and maximum size of heap memory, we can utilize the
-Xms
and-Xmx
JVM options. -
The
-Xms
option sets the heap memory’s initial size, while-Xmx
sets its maximum size. -
You can adjust these values according to the Java application’s requirements. For example,
-Xms512m -Xmx1024m
sets the initial heap size to 512 megabytes and the maximum heap size to 1024 megabytes.
For local development, you can use Example
Based on the minimum RAM requirements, the Magnolia instances for your production environment should have heap sizes in the following ranges. Remember that allocating more heap memory than the total available memory on the running machine (RAM) is not good practice. Doing so forces your environment to increase I/O operations exponentially to serialize the memory onto disk.
|
Optimizing CPU requests and limits
Setting CPU requests and limits can affect the stability of your Magnolia instances, causing:
-
overcommitment of CPU resources
-
slow responses from Magnolia
If you want to avoid handling things like CPU request and limits, and so forth, consider DX Cloud, a digital Platform as a Service (PaaS) offering. |