In this PR, I have made the following changes to optimize performance:
Changed the method of retrieving re-engagement module instances using PHP generators to minimize memory usage. View Code
Created individual ad-hoc tasks for each course module.
Previously, all users of each course module were fetched, and their availability was checked, causing significant slowdowns. To address this, I introduced an offset and batch size mechanism for each course module. Now, it processes users in batches of 1000. For subsequent runs, it processes the next set of 1000 users, continuing until all users are processed. If a course module has fewer than or equal to 1000 users, they will be processed in one run; for larger user sets, the task will complete in multiple runs. This ensures each course module is processed independently without affecting others. View Code
The overall processing time for the scheduled and ad-hoc tasks is significantly reduced with these changes. Consequently, it is now feasible to run scheduled and ad-hoc tasks multiple times a day instead of running a single lengthy task. This approach reduces memory usage, enhances execution time, and minimizes potential timeout issues associated with longer tasks.
In this PR, I have made the following changes to optimize performance:
The overall processing time for the scheduled and ad-hoc tasks is significantly reduced with these changes. Consequently, it is now feasible to run scheduled and ad-hoc tasks multiple times a day instead of running a single lengthy task. This approach reduces memory usage, enhances execution time, and minimizes potential timeout issues associated with longer tasks.