I currently have 2 users of my PHP app, deployed to Google App Engine (GAE) standard env. My aim is to have up to 100 users within a year.
All users execute the same app code, but have their own copy of the database.
Every user needs to sync data with 3 x third party APIs every minute. One of these APIs has a tendency to be very slow to process the request and respond. One of the APIs has some stringent throttles in place, by which it'll block access for a period if more than one API call is made in a 60 second period.
I currently have a cronjob running every minute, which grabs API keys from a user database, makes the three API calls, then repeats the process on the second user database. This works fine, but clearly will not scale.
Using Google App Engine resources, I've devised the following plan to improve the scalability of my app and cope with 100+ users:
- Cronjob executes PHP script every minute.
- PHP script gets list of DB's on server.
- PHP script iterates through list of DB's, creating 3 x GAE push tasks per DB (i.e. 1 per API, per user).
- Each push task calls app endpoint that handles sync process for a specific API.
I've not started writing the above routine yet, but it appears to work in principle. The potential issues I foresee are:
Cronjob hits 1 minute execution limit before PHP script has finished creating all of the push tasks. I assume this is unlikely, as I can bundle 100 tasks into a single addTasks() call, so the script execution should be < 10 seconds for 100 users.
Task queue backs up due to slow execution times, meaning API calls are made less frequently than every minute. This could cause some unmanageable data sync issues.
Task execution for a user is delayed, but as the cronjob is creating new tasks every minute, this may result in multiple tasks for the same user and same API being executed in less than a 60 second period, blocking access to one of the APIs.
Does anybody have any thoughts on the above, experience with task queues of this nature, or any tips on GAE push queues that could help me, please?