Users api endpoint crossing target error budget

We have seen api endpoint - GET /api/:version/users crossing target duration of 5s in many instances.

Related kibana logs -

https://log.gprd.gitlab.net/app/r/s/xvo2i_\ and_ https://log.gprd.gitlab.net/app/r/s/YS7gZ

There are some ways we can optimize UsersFinder

  1. We are ordering Users records twice

  2. once at API level here -

    users = UsersFinder.new(current_user, index_params).execute
            users = reorder_users(users)

    and another at Finder level, so that might be causing performance issues here.

May be there are others we need to dive into more details. Since this is an endpoint dealing with a lot of data, this one timing out is a great chance

Edited by Smriti Garg