Improve mod-permission performance

Description

In BugFest 2.1 performance analysis, we see 2755 mod-permissions entries out of 5817 total slow entries (see FOLIO-2039). Some of those entries are very slow (about 10s). There are only two simple small tables in mod-permissions module, so there is no reason to be so slow. Also given the frequency of mod-authtoken queries mod-permissions, this impacts the whole FOLIO system in a broad scale. We have to improve its performance. Given the relative static nature of permissions we probably should consider to use cache. Also checking for missing indexes and potentially duplicated calls. BTW, here is a sample query that takes about 2 seconds in an idle system. Ideally this should be improved to be at milliseconds level, so permission check does not impact system performance.

Implementation notes

1. Verify why the function is so slow and if there is a way to speed it up (e.g by introducing a DB index on the userId field).

1a. query by id should not use Criteria but optimized PostgresClient.getById or PgUtil.getById

1b. We suspect that the function may be issuing recursive DB queries – if that's the case try to optimize with a JOIN if not possible or viable use caching.

2. Cut down the total number of DB calls by introducing in-memory caching.

3. Add a jmeter test for looking up user permissions by userId to the platform-perf-test

Environment

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Jakub SkoczenJune 12, 2019 at 1:55 PM

will create a new ticket for the remaining caching work and include it in the sprint.

Adam DickmeissJune 12, 2019 at 8:40 AM

Closing.. If you have more work, create a new issue.

Hongwei JiJune 6, 2019 at 6:28 PM

BTW, here are some sample queries generated by the API call. There are hundreds of those related to permissions table.

Hongwei JiJune 6, 2019 at 6:15 PM

Added a few indexes to improve permission related query performance. https://github.com/folio-org/mod-permissions/pull/52

Hongwei JiJune 5, 2019 at 8:15 PM

Added a test case to the nightly perf test suite. https://github.com/folio-org/folio-perf-test/pull/106

Done

Details

Assignee

Reporter

Priority

Story Points

Sprint

Development Team

Core: Platform

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created May 31, 2019 at 2:40 PM
Updated June 12, 2019 at 2:01 PM
Resolved June 12, 2019 at 8:40 AM
TestRail: Cases
TestRail: Runs