How to handle NoAvailableSessionException (Modification of JCR session pool parameters)
The app/website becomes unreachable. Upon investigating, one can see similar kind of errors logged:
Caused by: javax.jcr.RepositoryException: org.hippoecm.hst.core.jcr.pool.NoAvailableSessionException: No session is available now for session pool 'default' since max active '100' has been reached.
This is usually caused by server load or repository session leak, or a combination of both. Few examples can be high traffic or a big publication action.
Cause for this can be:
high server load (more than 100 concurrent users, per server)
tomcat thread pool is left to defaults (200 connections) and request handling is slow due to external API calls which block session release
application code is closing sessions (calling session.logout() on pooled sessions)
The default repository session pool value can be modified as per need (unless you add more server nodes), assuming this is not an issue of session leak but expected traffic and/or load. If the issue lies with application code, please take appropriate actions to fix the code.
The solution mentioned below is about increasing the repository (HST) session pool.
Ideally, HST (repository) session count should be higher than tomcat connection count (or equal), otherwise tomcat will just accept connections which HST cannot handle.
Please note, by default tomcat sessions and HST (repository) sessions are configured as:
TOMCAT_MAXTHREADS = 200
Normally, each server request takes one HST session, unless you have some "external" calls within the same app,
For example, if your page A calls page B via a REST call for example (if you call http://localhost:8080/site/rest/B from page A, that will be another, separate request and therefore an extra HST session will be consumed)
To calculate how many HST sessions you need, you'll need to know:
avg. request time
maximum number of concurrent requests you need to handle
number of server nodes (delivery tier)
Once you know the above numbers, you can start sizing HST pool (assuming load balancer is in place and it is load balancing requests properly).
The default HST session value can be overridden in hst properties file
For reference, see here.