Performance of /oauth/token endpoint
See original GitHub issueIssue Description
Hi UAA team 😃
What version of UAA are you running?
version: 4.20.0
How are you deploying the UAA?
locally only using gradlew (osx, 2,6 GHz Intel Core i7)
Preface
Because I wanted to check what is UAA’s limit of token generation, I ran small performance tests, simple wrk call on /oauth/token - nothing fancy. Result was not splendid so I checked for what UAA spend its CPU time, I attached async-profiler and this is the output

UAA, is spending more than 50% of time in org.cloudfoundry.identity.uaa.zone.MultitenantJdbcClientDetailsService.loadClientByClientId
I made small experiment and I added simple “cache” to that class (just ConcurrentHashMap) that holds result of
ClientDetails details;
try {
details = jdbcTemplate.queryForObject(selectClientDetailsSql, new ClientDetailsRowMapper(), clientId, zoneId);
} catch (EmptyResultDataAccessException e) {
throw new NoSuchClientException("No client with requested id: " + clientId);
}
and with that piece of code included, UAA behaves a bit better on that path
only key signing (here 2048bits) and some fasterxml stuff.
here, I uploaded original SVG files (github don’t allow for uploading svg files in issue) before: https://github.com/KowalczykBartek/tmp-svg/blob/master/slow.svg after: https://github.com/KowalczykBartek/tmp-svg/blob/master/slow-but-better.svg
Question
Is it possible to add some caching on MultitenantJdbcClientDetailsService layer ? Does it makes sense from security point of view (or just any point of view 😄 ) to cache ClientDetails in memory (it can be cached on each instance without any sharing, like Redis or Memcached) ?
thanks !
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
@shamus This is an issue in UAA that deserves to be fixed. Instead of two DB requests, UAA is at 14. This considerably costs performance and limits scaling.
Requesting to reopen it.
We have been looking into the topic of caching also. Our observations are:
The simplest cache would be to have a request level cache, which avoids redundant calls for the same data. This would already take it from 14 calls to the database to 3.
Similar, with a request level cache this could be reduced to ~ 6 calls.
Caching can be implemented using the Spring cache mechanisms. Concerning the cache implementations, I see the following requirements: