I have "Google cloud function" in region europe-west1 (Belgium) which creates tasks in "Google cloud task queue" located in europe-west3 (Germany). It's similar to tutorial: https://cloud.google.com/tasks/docs/tutorial-gcf
It takes about 1-2 seconds for cloud function to create a task. It's not optimized solution because CF has to wait idle so long.
How to optimize task creation time?
Will moving of Cloud function and Task queue to one region significantly improve task creation speed?
Can I just stop cloud function when send "task queue creation" request and don't wait for response? Of course, it's bad practice and I would like to avoid this.
import { v2beta3 } from '@google-cloud/tasks';
// cloud function
(req, res) => {
const client = new v2beta3.CloudTasksClient();
...
// send "create task" request
client.createTask(...);
setTimeout(() => {
// Stop cloud function without processing of queue response
res.sendStatus(200);
}, 100);
}