We are currently developing an app with the google appengine for PHP an would like to optimize our costs.
At several times a day (morning, evening, midnight) we have a high amount of calculations that are started by a background-task. The sub-tasks take about 3-5 minutes each and are serialized (i.e. a finished sub-task puts the next sub-task to the query) in order to keep the number of used instances at the same time as low as possible. That leads to pretty long calculation times though.
Are there any times a day (like midnight) where instances have higher costs? Are there any ways to save some more costs? Are there any ways to improve the calculation times, for example by rearranging the independent calculations in a different order?
Thanks in advance!
Edit: Code-Example - all background-files look similar to this
require_once 'google/appengine/api/taskqueue/PushTask.php';
use google\appengine\api\taskqueue\PushTask;
$cron_data = get_cron_data();
if(empty($cron_data)) {
end_cronjob($cron_data["cron_id"]);
exit();
}
$data_array = db_select ( "SELECT * FROM db_table WHERE id > ".
$cron_data["data_id"] ." ORDER BY id ASC LIMIT 5");
if(empty($data_array)) {
end_cronjob($cron_data["cron_id"]);
exit();
}
foreach($data_array as $d) {
calculate($d);
update_cronjob($cron_data["cron_id"], $d["data_id"]);
}
$task = new PushTask('/this_task', ["cron_id" => $cron_data["cron_id"]]);
$task_name = $task->add();
exit();