core_course_get_courses fails with large return values

core_course_get_courses fails with large return values

by Ben Kahn -
Number of replies: 1

I’m dealing with an external app integrated into Moodle via webservices. Their app syncs our course data via a Moodle API call of core_course_get_courses, but the sync is failing currently at about 5 minutes.

I’m trying to figure out why it’s failing and trying to test/debug the API call they use. The API requests all courses from Moodle along with some JSON parameterized data about each course. I find that if I set an option in the call to only get one or a few courses it works fine. But when it runs without options and tries to get all 24K courses in the system (yes we have a lot of courses going back 6+ years) it fails with a generic Error: read ECONNRESET

I’ve grepped the Apache logs and don’t see that error anywhere.

I can run the call on dev, which has a lot fewer courses, with no issues.

I’ve asked the vendor engineers if they could possibly use one of the other Moodle APIs that looks for a subset of courses but they have not been willing to switch that up on their end.

Other than that the issue seems to be related to the size of the response Moodle is processing I’m not sure how to troubleshoot…I don’t think it’s a timeout issue as that would be a different error (I think)…. I’ll look at some of the server tuning on dev to see if maybe I can recreate the error.

I'm on Moodle 3.6.10 on a self hosted LAMP cluster running CentOS 6.10 and PHP 7.0


Average of ratings: -
In reply to Ben Kahn

Re: core_course_get_courses fails with large return values

by Ben Kahn -
I was able to resolve this by changing some Apache settings:
I enabled KeepAlive connections, set Max Keepalives to 500, and set KeepAlive timeout to 360 seconds. After that the API call worked when testing, and the external app was able to sync courses.
This DID make my server unhappy the next morning when more than 500 people were logged in at once and I had to quickly revert to my old settings. ALWAYS keep a backup of your config files when making changes! smile