restapi: Optimization of the GET /vms?detail=main REST API request - #1026
Open
sermakov-orion wants to merge 1 commit into
Open
restapi: Optimization of the GET /vms?detail=main REST API request#1026sermakov-orion wants to merge 1 commit into
sermakov-orion wants to merge 1 commit into
Conversation
Reduce the number of database requests when retrieving certificate details for the requested VMs Signed-off-by: Stepan Ermakov <sermakov@orionsoft.ru>
sermakov-orion
requested review from
ahadas,
bennyz,
didib,
emesika,
michalskrivanek,
sgratch and
smelamud
as code owners
May 29, 2025 07:34
0ffer
approved these changes
May 29, 2025
| } | ||
| } | ||
|
|
||
| public static Map<Guid, Certificate> getDisplayCertificatesForMultipleEntities(BackendResource res, List<Guid> vmIds) { |
Collaborator
There was a problem hiding this comment.
Instead of adding this addDisplayCertificate and getDisplayCertificatesForMultipleEntities could it not be a possibility to instead break out of the addDisplayCertificate function on cases that it is known there will not be a certificate present? This would reduce the added complexity but still result in the wanted output of less queries being run towards the backend. For example, a VM that is down returns null when the QueryType.GetVdsCertificateSubjectByVmId is ran. Thus this could be seen as an unneeded query and the function could be exited before this is executed.
Collaborator
There was a problem hiding this comment.
Any follow up on this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduce the number of database requests when retrieving certificate details for the requested VMs
Changes introduced with this PR
This fix optimizes GET /vms?detail=main REST API request. In case when there is a parameter detail=main in the request:
Old behavior - for each particular VM invoke DisplayHelper.addDisplayCertificate(BackendResource res, Vm vm) which:
Optimized behavior - for all VMs invoke DisplayHelper.getDisplayCertificatesForMultipleEntities(BackendResource res, List vmIds) which:
So, the optimization significantly reduced the number of queries. Significantly reduced the number of calls to vmDynamicDao and vdsStaticDao (because in general the number of unique hosts is much less than the number of VMs), and reduced the number of reads of the certificate content.
Are you the owner of the code you are sending in, or do you have permission of the owner?
Y