[API] Sequence of "create group" requests runs slowly, and can crash API server
A user reported that creating many projects at once resulted in extreme slowdown and eventually crashing the API server unless the create requests were throttled.
Creating a project (or any other group) also refreshes the permissions graph in the same transaction.
This makes the API call slow, but we intend/expect that other API calls can proceed while the update is in progress, so other (non-permission-modifying) API calls aren't expected to be slowed down.
The approach would be:
- Accept an
asyncparam to permission-changing calls that would delay the permission graph update for a server configurable number of seconds in the future.
- When updating the permission graph asynchronously, use the
CONCURRENTLYparameter to avoid blocking
SELECTwhile it’s being updated. (PostgreSQL 9.4 feature, check API server’s dependency requirements).
- Use status 202 (Accepted) on async call responses.
- Make a performance analysis comparison to make sure the issue is solved.
- Update documentation.