-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Slow API requests with 2.8 / master #4163
Comments
@t-book this is indeed something that must be better inspected. I guess it is the result of mixing old/new design mechanisms. Putting in on my todo list. |
Thanks a lot Alessio! |
@t-book I have digged a bit more on this topic (I'm on master branch right now) and those are my current findings:
https://github.com/GeoNode/geonode/blob/master/geonode/api/resourcebase_api.py#L714 In particular, this is trying to enrich the Layer details in order to populate the JSON output. By removing some details, e.g. owner name, keywords, links and so on, it should reduce and/or completely bypass additional DB queries.
Do you have the chance to debug a bit this behavior on 2.8.x also? |
Dear Alessio, thanks a lot providing your findings. I´ll have a look at 2.8 and come back! Thanks! |
I would add that not having a cache for the API requests sharpens this even more... |
Dear @afabiani, it was a busy day. So only a brief update. I can confirm the length of the obj is 20 as the api GET forces but
My guess is by this we just reduce the amount of selected fields? Just to be sure my testing is correct:
Count: 2596 selects which reflects more or less the total amount of 2286 layers. I will have a closer look by tomorrow and will try to just return an empty object. Let´s see if this reduces the queries. Thanks a lot for your help! |
@t-book uhm that's weird. In that case, I don't understand where those additional queries come from if the length of the obj is 20. On my tests I only looked at the queries printed by "django" logs at DEBUG level. Could you maybe check if the method "get_visible_resources" adds such overhead? However, in the last case, it won't be trivial updating the logic, since in that case we will allow everyone fetching private/unpublished layers too. |
@afabiani Thanks for your feedback. I´ll test your suggestion and double check with django debug toolbar. I´ll keep you updated! |
@afabiani I´ve digged a bit deaper. You´re right we can lower the load a bit by removing fields. But this did not significantly speed up the request. The easiest test I could think of:
Is it possible that it´s the queryset https://github.com/GeoNode/geonode/blob/master/geonode/api/resourcebase_api.py#L882 Anyways before rocking the boat it would be |
de-hydratation is detrimental for performances! Avoid to use it the more you can. Currently I am using a custom API, you can check it out here: https://github.com/cga-harvard/worldmap/blob/2.10.x/worldmap_site/api.py It is very easy to enable it in the template of the geonode project (no need to fork): This is extremely fast with 20,000+ layers: |
@capooti big thumbs up! – thanks! |
and my recent commit 704b8d5 exacerbates this even more :) |
@giohappy Can we rely on apps [1] or USE_GEOSERVER = False [2] @capooti Just testing with > 5000 layers indeed your version is way faster ... [1] https://github.com/GeoNode/geonode/blob/master/geonode/settings.py#L299 |
@t-book some checks to distinguish between the backends are already in place, but most of the dehydrated informations affect both. |
@t-book glad you like it. Not sure if all filters are enabled, that also explains the speed @giohappy I think it is the combination de-hydratation/ORM to slow down things when you have many resources. I remember when I wanted to fix our problems, looking at the Django toolbar the queries where run for all the resources and not only for the paginated ones. I tried to figure out the problem but couldn't so I prefered to start API from scratch keeping things simple. |
should be fixed now, let's re-open this if this occurs again. |
Hi,
when requesting the layers view (/api/layers/?limit=20&offset=0) with GeoNode 2.8 (+master) postgreSql is hit for every layer the user has permissions for (direct SELECT WHERE ID = N):
This is resulting in slow loading (slow TTFB) And shows more clear on content heavy GeoNodes.
Can one shed some light if this is by design of tastypie/oauth2 or why this overhead is needed (wasn´t with 2.4)? – If this is needed I would expect the db queries only for the requested subset (LIMIT 20)?
Thanks,
– Toni
The text was updated successfully, but these errors were encountered: