REST api initial introspect call is taking longer time

Hi Team,

We are new to keycloak, using rest api’s for authentication purpose.
Using 15.0.1 version.

We are using http api to call keycloak rest apis. While running in lambda function and hitting the keycloak introspect call. The initial call is taking longer time of around >5seconds to get response. Later immediate calls are faster < 200ms.

It happens randomly. At few intervals.

Kindly help on what could be the reason. DB is RDS.

I bet that’s because user/client details (e. g. roles,…) are not in the cache. You should to disable all mappers which you don’t need. Also is a good idea to make offline token validation without calling introspection endpoint.

It’s test env. We have a very low user count. Users and roles less than 100. Does not make sense of using cache. And if keycloak is supporting Rest API call, that should not ideally consume 5Sec for a api call.!
What kind of offline token you mean here?

I would recommned some doc to see how OIDC protocol works, how public key can be used for token verification without calling introspection endpoint. Also keycloak doc to see why cache is used (keyword infinispan).