@juliadeanne , good afternoon!
I’m facing the exact same issue as @w268wang reported, and in my case, even after setting min instances in my function to 2, I’m getting 504 errors whereas the function is not even being executed, just like in his case.
It happens at completely random times in a day, but always once every day. Every three hours a cloud schedule enqueues an X number of tasks where each task makes a request to my function. The number of X varies, but in average it is 20. For instance, earlier today there were 12 tasks enqueued, and at least 6 of them got the 504 error after 300 seconds, although they ran fine upon automatic retry (the queue is set to make 5 retries).
Considering my function is defined with 2 GB memory and 10 max instances, and that it allocates an average of 260 MB and takes approximately 15 seconds on a successful request, then it should be handling concurrency just fine with no more than 2 instances in a 12 request burst scenario like I described.