How to configure Openfire's caches

Openfire uses caches to improve performance. Caches can be configured to hold more or less objects in memory and also the amount of time an object will be kept in memory. Big caches can improve performance but very big caches may decrease it since more memory will be used and Java may have to work hard to make room for other objects in memory. In summary, the proper size of the cache should be estimated for each installation based on the number of concurrent users, the roster size, vCard size, number of groups, etc.

Openfire does not provide the option to configure cache properties from the admin console in an easy way. For now you have to create new system properties in the admin console and set the required value. After changing a cache property you will need to restart the server so that the change is actually used.

These are the names of the properties that you can define and configure. The *.size properties define the max size in bytes the cache may be. The *.maxLifetime defines the default max lifetime of the cache, in milliseconds.?

More caches are defined in http://www.igniterealtime.org/fisheye/browse/svn-org/openfire/trunk/src/java/org /jivesoftware/util/cache/CacheFactory.java?r=trunk

Cache
Size
Expiration
vCard
cache.vcardCache.size
cache.vcardCache.maxLifetime
User
cache.userCache.size
cache.userCache.maxLifetime
Existence of remote users
cache.remoteUsersCache.size
cache.remoteUsersCache.maxLifetime
Roster
cache.username2roster.size
cache.username2roster.maxLifetime
Group
cache.group.size
cache.group.maxLifetime
Group Users
cache.userGroup.size
cache.userGroup.maxLifetime
Privacy List
cache.listsCache.size
cache.listsCache.maxLifetime
Support of XEP-133 by remote servers
cache.multicast.size
cache.multicast.maxLifetime
Offline Message
cache.offlinemessage.size
cache.offlinemessage.maxLifetime
POP3 auth users
cache.pop3.size
cache.pop3.maxLifetime
File Transfer
cache.fileTransfer.size
cache.fileTransfer.maxLifetime
LDAP
cache.ldap.size
cache.ldap.maxLifetime

Some values are set in http://fisheye.igniterealtime.org/browse/openfire/trunk/src/java/org/jivesoftwar e/util/cache/DefaultLocalCacheStrategy.java?hb=true

The information below contains the settings for Openfire 3.7.1.

Default values for size is 256 KB and lifetime 6 hours.

cache.fileTransfer.size
128 * 1024
cache.fileTransfer.maxLifetime
1000 * 60 * 10
cache.multicast.size
128 * 1024
cache.multicast.maxLifetime
JiveConstants.DAY
cache.offlinemessage.size
100 * 1024
cache.offlinemessage.maxLifetime
JiveConstants.HOUR * 12
cache.pop3.size
512 * 1024
cache.pop3.maxLifetime
JiveConstants.HOUR
cache.transferProxy.size
-1
cache.transferProxy.maxLifetime
1000 * 60 * 10
cache.group.size
1024 * 1024
cache.group.maxLifetime
JiveConstants.MINUTE * 15
cache.groupMeta.size
512 * 1024
cache.groupMeta.maxLifetime
JiveConstants.MINUTE * 15
cache.javascript.size
128 * 1024
cache.javascript.maxLifetime
3600 * 24 * 10
cache.ldap.size
512 * 1024
cache.ldap.maxLifetime
JiveConstants.HOUR * 2
cache.listsCache.size
512 * 1024
cache.offlinePresence.size
512 * 1024
cache.lastActivity.size
128 * 1024
cache.userCache.size
512 * 1024
cache.userCache.maxLifetime
JiveConstants.MINUTE * 30
cache.remoteUsersCache.size
512 * 1024
cache.remoteUsersCache.maxLifetime
JiveConstants.MINUTE * 30
cache.vcardCache.size
512 * 1024
cache.faviconHits.size
128 * 1024
cache.faviconMisses.size
128 * 1024
cache.routeServer.size
-1
cache.routeServer.maxLifetime
-1
cache.routeComponent.size
-1
cache.routeComponent.maxLifetime
-1
cache.routeUser.size
-1
cache.routeUser.maxLifetime
-1
cache.routeAnonymousUser.size
-1
cache.routeAnonymousUser.maxLifetime
-1
cache.routeUserSessions.size
-1
cache.routeUserSessions.maxLifetime
-1
cache.componentsSessions.size
-1
cache.componentsSessions.maxLifetime
-1
cache.connManagerSessions.size
-1
cache.connManagerSessions.maxLifetime
-1
cache.incServerSessions.size
-1
cache.incServerSessions.maxLifetime
-1
cache.sessionsHostname.size
-1
cache.sessionsHostname.maxLifetime
-1
cache.secretKeys.size
-1
cache.secretKeys.maxLifetime
-1
cache.validatedDomains.size
-1
cache.validatedDomains.maxLifetime
-1
cache.directedPresences.size
-1
cache.directedPresences.maxLifetime
-1
cache.serverFeatures.size
-1
cache.serverFeatures.maxLifetime
-1
cache.serverItems.size
-1
cache.serverItems.maxLifetime
-1
cache.serversConfigurations.size
128 * 1024
cache.serversConfigurations.maxLifetime
JiveConstants.MINUTE * 30

3 Likes

I remember using ā€œcache.User.sizeā€ for User cache.

Anyway, very good post.

Does anyone know what are the default values for *.maxLifetime attributes? (i mean if we havenā€™t set the values of these properties from the admin console, what default values does openfire use)??

Thanks

Take a look at the source (at the link above),

some examples:

cache.group.maxLifetime", JiveConstants.MINUTE * 15,

cache.userCache.maxLifetime", JiveConstants.MINUTE * 30

Does cache.userGroup exist anymore? Looking at the 3.6.4 source code it looks like the only two caches related to groups are the group and the group metadata oneā€¦

cacheNames.put(ā€œGroupā€, ā€œgroupā€);

cacheNames.put(ā€œGroup Metadata Cacheā€, ā€œgroupMetaā€);

as referenced by GroupManager:

// Initialize caches.

groupCache = CacheFactory.createCache(ā€œGroupā€);

// A cache for meta-data around groups: count, group names, groups associated with

// a particular user

groupMetaCache = CacheFactory.createCache(ā€œGroup Metadata Cacheā€);

What is the property value for ā€œClient Session Info Cacheā€ ???

Canā€™t seem to find anything about it What for is this cache setting used?

Currently it is default set to 0.25 MB and Current Size is always 0.00 MB even though we have hundreds of ongoing sessions.

Hi every one, What was value for cache.username2roster.maxLifetime (i mean if we havenā€™t set the values of these properties from the admin console, what default values does openfire use)? is there anyone can help me cause we are having a problem with our openfire server hereā€™s the error 2013.08.02 16:50:41 org.jivesoftware.util.cache.DefaultCache - Cache Roster was full, shrinked to 90% in 0ms.

I already set it to 1mb but error log state that it was full again. what should i do? Thanks hoping for you reply

In Russian http://lapitoop.ru/tuning-cache-openfire/


Tuning of cache Openfire

Openfire uses a cache for effective work.

But the size of a cache by default can appear is small, if at you in jabber many users/groups are connected.

Thus in broad gulls about errors you can see set of messages of such plan:

Cache Roster was full, shrinked to 90 % in 0ms.

For the decision of this problem you should add following parametres:

cache.group.size = 5242880

cache.group.maxLifetime = 3600000

cache.username2roster.size = 5242880

cache.username2roster.maxLifetime = 3600000

cache.userGroup.size = 5242880

cache.userGroup.maxLifetime = 3600000

cache.userCache.size = 2097152

cache.userCache.maxLifetime = 3600000

cache.groupMeta.size = 2097152

cache.groupMeta.maxLifetime = 3600000

To add new options follows through Š²ŠŗŠ»Š°Š“Šŗу

Server-> Server Manager-> System Properties.

After updating of options it is necessary to restart service.

1 Like

Thanks for the advise, I already tried to change property volue cache.username2roster.size of to -1 and restart the openfire and after that it turns to unlimited by the way thank for you reply a really appreciate it. as of now we are not having a problem after iā€™ve change itā€¦

Anyone knows how to disable the cache of a specific plugin?

Iā€™m using ā€˜fastpathā€™, and I need to make frequent updates on some fields inside Text setting, but directly to mysql, outside the interface, and the value isnā€™t updating, all because of the cache.

@Matheus, did you ever get a working solution to this?

I am getting cache size full issue ā€¦I can easily set -1 but i donā€™t feel thats a good solution. Why Openfire doesnā€™t have LRU implementation of cache?

If i set cache to unlimited wonā€™t it starve whole openfire of memory as cache would keep on growing? I ran same system for over 6 months and worked fine and had more traffic (active 1200 users) than current traffic (800 users) . I am wondering why openfire is giving issue of cache now and not earlier.

Please keep discussion in the discussion in the forum. It is hard to discuss something in document comments.

Sure . Would respect that. Here is the link to discussion in the forum. Cache implementation of Openfire - Is it LRU?

Thanks for reverting back.

Hi All,

Can anyone let me know what cache I have to use for Group offline instant message?

Thank you in advance.