Exo Platform uses caches for almost all applications. Therefore, how an application performs can be significantly affected by the cache settings.
This article will help you understand the importance of cache tuning in eXo Platform and how to find the best settings for your installation.
Why is cache tuning important? Do the default settings fit all eXo Platform installations?
eXo Platform can scale from laptop demos to a multi-server with hundreds of thousands of users. But the default settings are preconfigured for demo and test purposes only. These default values ensure that we avoid JVM out of memory errors – when memory consumption exceeds the maximum allowed memory size.
This is why the preconfigured cache parameters are set to be small. However, increasing the JVM max heap size will not necessarily help to improve performance if you do not tune cache parameters correctly switch the Platform usage.
To give a common example, setting JVM max heap size to 16GB without cache tuning could lead to using just 5GB, when the application needs more. You need to remember that the cache maximum size (maximum objects per cache) is limited and doesn’t directly correlate with the JVM max heap size.
So the cache parameters couldn’t be common to all installations and should be determined switch your installation use cases.
What happens if I don’t change the default values?
If the cache size parameter is limited to 30 entries and you have 40 entries to add in the cache, you will eventually observe a decrease in performance. This can happen for many reasons, but the most common is that the cache has reached its maximum allowed elements. At this point, the information required by the application must be retrieved from stores (e.g. RDBMS, LDAP) instead of the application cache.
This is more noticeable in cluster mode because of write and synchronisation messages between cluster members/nodes.
What should I take into account when increasing cache capacity?
If you increase the cache capacity, you should also increase the JVM max heap size.
What cache parameters can I tune?
Before you start to tune caches, you should estimate and calculate the following variables:
- JVM Xmx and Xms.
- Each cache entry consumption estimation in memory. You can estimate the size of cache objects by generating a heap dump.
- The estimated maximum concurrent users that the system has to support. Some caches require as a minimum size the number of concurrent users, such as user’s activities cache and user’s people network cache.
- The lifecycle of the cached objects for each cache. Is the cache content frequently changed?
These answers will help you to improve the behaviour, performance, capacity and horizontal scalability of your system.
In eXo Platform, there are three types of cache:
- Java Content Repository (JCR; data, indexes, locks): no need to tune these – parameters are optimal for almost all conditions.
- Identity management caches (IDM): no need to tune these – rarely used.
- eXo Services: you can tune these following the instructions in this document.
How do I monitor cache statistics?
You can monitor cache size, miscount and hitcount using JMX. (An example of a cache MBean exo:portal=portal,service=cache,name=ActivitiesCache.)
For more information on eXo Platform’s management and monitoring gadgets, read this document.
I wanted to share with you how tuning caches can make the difference between a performing system and an installation that doesn’t work well. However, you will need to test this before going live.
As you probably know, no system should go live without a good monitoring system and performance benchmarking phase to ensure proper stability and scaling. Of course, there are many factors to consider in the performance benchmarking phase – such as network bandwidth, blocking operations and systems and RDBMS performance. Application caches is just another to add to the list.
If you need any help with this process, please don’t hesitate to ask our experts.