Closed (fixed)
Project:
Feeds
Version:
8.x-3.x-dev
Component:
Miscellaneous
Priority:
Minor
Category:
Feature request
Assigned:
Reporter:
Created:
20 Jun 2021 at 08:30 UTC
Updated:
9 Nov 2021 at 09:19 UTC
Jump to comment: Most recent
I recently worked on a project that heavily relied on the feeds module, I realized when feeds import was happening it took more than normal to get a response on any page, and I thought maybe making the http fetch request asynchronous would somehow help improve this.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bahson commentedComment #3
megachrizCan you explain how that would work? Feeds cannot import content if it hasn't been fetched yet. And you can already configure Feeds to run imports during cron runs, so I assume the webserver would already fetch in a separate request in this case.
Comment #4
bahson commented@megachriz, here is a thought that inspired this;
Let's assume the feeds source (website) response time is 20 secs (maybe lower), and you have like 10+ sources to import from or at least check if there's something new.
Making this asynchronous would mean, maybe less execution time than waiting (20 sec) * (number of sources).
Not sure if other parts need to be tweaked to achieve this, but I hope to test first even the initial idea.
Comment #6
bahson commentedComment #7
bahson commented@MegaChriz, sure the content imports correctly,
About performance improvement, let me re-run the imports severally with current and previous implementation and report back (will edit this comment with the answer to the last question.)
Update:
About performance improvement, it sure does improve: I can get a response faster on the homepage (views listings with freshly imported content), than with previous implements specifically when cron is running.
Comment #8
megachrizOkay, good :)
I'm planning to try it. I hope I can get to that soon. Feel free to post a new comment if I haven't done so in a few weeks from now.
Comment #9
bahson commentedAwesome, I sure will sometime after August.
Comment #10
megachrizSo I tested this change, but I didn't notice any improvements on the amount of time it took to import.
This is what I did:
sleep(20);.drush core-cron;drush core-cron.Without the code change, the import of all four feeds took about 1 minute and 36 seconds. I rerun the test a few times to make sure that this import time was constant.
And with the code change, the import still took 1 minute and 36 seconds.
So I assume that the performance improvement is elsewhere? I see you wrote that the homepage response was faster. So does that mean that a cron run/feeds import makes the site a bit slower?
I'm not too experienced with Guzzle, but looking at the docs about async requests, would the import times perhaps speed up more if using a callback on the
then()method?Comment #11
megachrizI could of course also merge it as is. While I noticed not any direct improvements, nothing did break either.
Comment #12
bahson commentedYeah, the import should take the same time, but the improvement is somehow subtle, in that, the request part is not blocking, and other scripts can be executed as the cron fetch request is being processed.
Comment #14
megachrizAlthough the speeds of imports could probably be improved more, I decided to just merge this now. I don't think I'll get to focus on improving the import performance anytime soon and this change would then have to wait a long long time.
Thanks for contributing!
Comment #15
bahson commentedYou're most welcome, and thanks to you too, for the feeds module to be precise.