Cache Performance Tuning
Confluence performance can be significantly affected by the performance of its caches. It is essential for the administrator of a large production installation of Confluence to tune the caches to suit its environment.
There are several configurable parameters for each of the cache regions, most notably cache size, cache expiry delay and eviction policy. In most cases, cache size is the parameter you would want to change.
To change the size of a cache:
- Go to > General Configuration > Cache Management.
- Choose Show Advanced View.
- Choose Adjust Size next to the cache you want to change.
To modify other parameters you can modify the cache configuration files manually.
On this page:
Cache tuning example
As an example of how to tune Confluence's caches, let's have a look at the following table:
Caches | % Used | % Effectiveness | Objects/Size | Hit/Miss/Expiry |
---|---|---|---|---|
Attachments | 87% | 29% | 874/1000 | 78226/189715/187530 |
Content Attachments | 29% | 9% | 292/1000 | 4289/41012/20569 |
Content Bodies | 98% | 81% | 987/1000 | 28717/6671/5522 |
Content Label Mappings | 29% | 20% | 294/1000 | 4693/18185/9150 |
Database Queries | 96% | 54% | 968/1000 | 105949/86889/83334 |
Object Properties | 27% | 18% | 279/1000 | 5746/25386/8102 |
Page Comments | 26% | 11% | 261/1000 | 2304/17178/8606 |
Users | 98% | 5% | 982/1000 | 6561/115330/114279 |
The maximum size of the caches above is 1000 (meaning that it can contain up to 1000 objects). You can tell when a cache size needs to be increased because the cache has both:
- a high usage percentage (above 75%)
- a low effectiveness percentage.
Check the 'effectiveness' versus the 'percent used'. A cache with a low percent used need not have its size lowered; it does not use more memory until the cache is filled.
Based on this, the sizes of the "Attachments", "Database Queries", and "Users" caches should be increased to improve their effectiveness.
As the stored information gets older or unused it will expire and be eliminated from the cache. Cache expiry may be based on time or on frequency of use.
There is not much that you can do with a cache that has both a low percentage of usage and effectiveness. Over time, as the cache is populated with more objects and repeat requests for them are made, the cache's effectiveness will increase.
Finding the configuration file
Cache configurations are stored in <confluence-home>/shared-home/config/cache-settings-overrides.properties
For Confluence Data Center (clustered) it can be found in <confluence-shared-home>/config/cache-settings-overrides.properties
(in the shared home directory for the cluster).
Cache key mappings
The cache configuration file configures caches by their keys. To find out a cache key hover your mouse over the cache name in the Cache Management screen.
Caching in Confluence Data Center
In Confluence Data Center (clustered) you have a distributed cache and a cluster node-local cache. The Cluster Management page will indicate cluster distributed cache and cluster node-local cache.
The cache configuration file is stored in the shared home directory for the cluster.
Important caches
The following suggestions are general guidelines. In cases of large databases, 20-30% of the size of the table may be unnecessarily large. Check the effectiveness and percent used categories in the cache for more specific assessments.
- Content Objects cache (
com.atlassian.confluence.core.ContentEntityObject
)
should be set to at least 20-30% of the number of content entity objects (pages, comments, emails, news items) in your system. To find the number of content entity objects, use the queryselect count(*) from CONTENT where prevver is null
. - Content Body Mappings cache (
com.atlassian.confluence.core.ContentEntityObject.bodyContents
should be set to at least 20% of the number of content entity objects (pages, comments, emails, news items) in your system. To find the number of content entity objects, use the query)
select count(*) from CONTENT where prevver is null
. Embedded Crowd Internal User cache (
com.atlassian.crowd.model.user.InternalUser
)
should be set to the number of users you have in the internal directory. You can discover this number by using the following SQL:SELECT COUNT(*) FROM cwd_user u JOIN cwd_directory d ON u.directory_id = d.id AND d.directory_name = 'Confluence Internal Directory';
Embedded Crowd Users cache
com.atlassian.confluence.user.crowd.CachedCrowdUserDao.USER_CACHE
should be set to the number of rows in the cwd_user table.SELECT COUNT(*) FROM cwd_user u;
- Space permissions by ID cache (
com.atlassian.confluence.security.SpacePermission
)
should be set to the number of space permissions in your deployment (a good rule of thumb is 20 times the number of spaces). You can find the number of space permissions using the queryselect count(*) from SPACEPERMISSIONS
.
Monitoring the contents of a cache
To monitor what is in a cache:
- In your browser go to <
confluence-URL>/admin/cachecontents.jsp
All caches that contain items will appear. - Select a cache from the list.
Notes
- To improve performance of a large Confluence site, we recommend that you move the caching of static content from the JVM into Apache. This will prevent the JVM from having a number of long running threads serving up static content. See Configuring Apache to Cache Static Content via mod_disk_cache.