Semaphores keep getting stuck and cause slow performance due to UserCriteriaLoader.getAllUserCriteriaIssue Multiple stuck default semaphores and all the semaphores were stuck at the same function getAllUserCriteria() A case may be opened for your instance with the message: "Our internal monitoring has detected an issue with your instance, which is being investigated. For more information please contact Technical Support, or update this Case. The alert originated on <instance> node." ***Note that the above message could be for any performance reason, not just the use of getAllUserCriteria API. Check this article for Troubleshooting Stuck Default Semaphores ReleaseThe issue can appear on any version of ServiceNow, since the API is installed with the base systemResolutionUser Criteria is often used to implement audiences and access, as it is a customer-friendly and useful tool to define user groups without explicitly defining which users belong to the group. User Criteria is used often in Service Portal, but can be used anywhere a background script is run. However, there are a few things that should be considered when implementing user criteria into your application. Performance Each User criteria record is slow to process, especially scripted user criteria. Scripted user criteria may take at least as long as the script takes to execute, and therefore should be optimized where possible. It is always a best practice to evaluate the minimum number of user criteria as necessary. Never use the API call: sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID());. This deprecated API will cause the platform to gather all active user_criteria records and evaluate the user against each one. If there are thousands of user criteria, the API call can take several seconds on its own. Instead, use either alternative: sn_uc.UserCriteriaLoader.userMatches(String userID, Array[String] userCriterion) -> returns true if any userCriteria matches the provided user. or sn_uc.UserCriteriaLoader.getMatchingCriteria(String userID, Array[String] userCriterion) -> returns an array of userCriteria sys_ids that matched the provided user. String userID is usually the current user, `gs.getUserID()` Array[String] userCriterion is a list of user criteria sys_ids, ie: `['c01ad6a9c361de10e65b04bdc001311e', '124c2ca22bb9f1002f42729fe8da152e', ...]` Between these two APIs, userMatches is faster and should be preferred.