Hi all,
I am running into performance issues within a confluence instance when fetching users data to build a custom endpoint.
Yes the number of users is quit high (2000 users) but I really wonder how the UI is managing when the JavaAPI is not capable.
So what I am trying to do:
The logic works fine and for other groups (there are only a few hundred users) it works (even not really satisfying performance). As soon as fetching user objects kicks in it slows down.
When calling the script via endpoint I´m running into (kinda) timeout:
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /rest/scriptrunner/latest/custom/<nameOfEndpoint>.
Reason: Error reading from remote server
I built the same functionality in Jira too and the UserUtil doesn´t have any problem with a higher amount of users.
See my code from confluence scriptrunner rest-endpoint:
<endpoint>(
httpMethod: "GET"
) { MultivaluedMap queryParams, String body ->
def maGroups = ["group_01", "group_02", "group_03"] as Collection<String>
def billGroups = userAccessor.getGroupsAsList()?.findAll { it.name.startsWith('verrechnung-') && maGroups.contains(it.name) }
log.warn(billGroups)
def billUsers = [] as List<String>
def users = []
billGroups.each { group ->
// def billUsers = [] as List<String>
billUsers.addAll(userAccessor.getMemberNamesAsList(group))
// log.warn("${group.name}: ${billUsers}")
log.warn("each: " + group.name)
log.warn("billUsers: " + billUsers)
log.warn("billUsers size: " + billUsers.size())
}
billUsers.each { userName ->
// def user = Users.getByName(userName)
def user = userManager.getUser(userName)
def billGroupsOfUser = userAccessor.getGroupNamesForUserName(user.name).findAll { it.startsWith("verrechnung-") }
def createdDate = crowdService.getUser(user.name).asType(TimestampedUser).createdDate.format('yyyy-MM-dd')
def userSpaces = permissionFilter.getPermittedSpaceKeysForUser(user)
users.add([
billGroup: billGroupsOfUser.join(","),
userName: user.name,
fullName: user.fullName,
email: user.email,
created: createdDate,
spaces: userSpaces.join(", ")
])
}
log.warn("users size(): " + users.size())
def response = [users:users]
log.warn("response: " + response)
return Response.ok(new JsonBuilder(response).toString()).build()
}
Edit: more facts
Users:
users size(): 879
Time:
Elapsed: 34847 ms
CPU time: 20819 ms
Any help appreciated.
Thanks in advance.
Best
Stefan
Hello @Stefan Salzl ,
Did you check the internal implementation of the Java code - maybe you can compare the one in Jira and Confluence and see why it is so?
There are some other APIs that can be used for accessing user data - maybe they can be more effective if correctly combined :)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.