-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Add project name search parameter for project listing for the API server usecase 🚨 #7066
🐛 Add project name search parameter for project listing for the API server usecase 🚨 #7066
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7066 +/- ##
==========================================
- Coverage 88.30% 83.67% -4.63%
==========================================
Files 1484 752 -732
Lines 58987 35336 -23651
Branches 1299 262 -1037
==========================================
- Hits 52088 29569 -22519
+ Misses 6697 5707 -990
+ Partials 202 60 -142
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
services/web/server/src/simcore_service_webserver/projects/_crud_api_read.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice analysis! Thanks a lot for the fix
…:matusdrobuliak66/osparc-simcore into bugfix/listing-of-projects-in-api-server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!
services/api-server/src/simcore_service_api_server/services_http/webserver.py
Show resolved
Hide resolved
services/api-server/src/simcore_service_api_server/services_http/webserver.py
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
e2aeff5
into
ITISFoundation:master
What do these changes do?
On osparc.io, we observed overloading of the database.
Currently, our database has only 2 CPUs. This graph shows that, on average, we would need 70 CPUs to handle the traffic.
The issue is primarily when api server calls "list projects" query, which involves multiple column searches, especially for the end-to-end testing user (who has 1,800 hidden projects).
Initial analysis showed that the query takes 93 seconds to execute. Since the API server does not require multi-column search, I performed some tests by removing unnecessary search fields and leaving only the project name. This reduced the query time to 150 ms. Furthermore, changing ILIKE to LIKE, which is even lighter, reduced it further to 73 ms.
This is why I introduced a new filter field specifically for the API server, projects_name_search. This approach can also be easily hotfixed if needed.
After further investigation, it turned out that the issue is not directly related to multi-column search itself but rather to how the database engine plans the execution. For some reason, when multiple joins and multiple text ILIKE filters are involved, the engine appears to get confused and does not create an optimal execution plan. For example, it first joins the projects table with the project_tags table (30,000 projects × 4,000 project tags ≈ 120,000,000 rows) and only afterward performs the multi-column search.
By simplifying the query for the API server use case, the engine started to create a more optimal execution plan.
Other steps that should be taken:
@cancel_on_disconnect
to each route.Related issue/s
How to test
Dev-ops checklist