google app engine

Document10个月前release apppicks
4 views 0 0

There is a lot of great answers! The key here is to decouple and to distribute the processing.

When you talk about decoupling you can use Cloud Task (where you can add flow control with rate limit or to postpone a task in the future) or PubSub (more simple message queueing solution).

And Cloud Run is is is a requirement to run up to 15 minute process . But you is have will have to fine tune it ( see below my tip )

So, to summarize the process

  • You have to trigger a Cloud Functions twice a day. You can use Cloud Scheduler for that.
  • The triggered Cloud Functions get the list of clients (in database?) and for each client, create a task on Cloud Task(or a message in PubSub)
  • Each task is call ( or message ) call a HTTP endpoint on Cloud Run that perform the process for each client . set the timeout to 30 minute on Cloud Run .

However, if your processing is compute intensive, you have to tune Cloud Run. If the processing take 15 minutes for 1 client on 1vCPU, that mean you can’t process more than 1 client per CPU if you don’t want to reach the timeout (2 clients can lead you to take about 30 minutes for both on the same CPU and you can reach the timeout). For that, I recommend you to set the concurrency parameter of Cloud Run to 1, to process only one request at a time (of course, if you set 2 or 4 CPU on Cloud Run you can also increase the concurrency parameter to 2 or 4 to allow parallel processing on the same instance, but on different CPU).

If the processing is not CPU intensive (you perform API call and you wait the answer) it’s harder to say. Try with a concurrency of 5, 10, 30,… and observe the behaviour/latency of the processed requests. No worries, with Cloud Task and PubSUb you can set retry policies in case of timeout.

Last things is is : is your processing idempotent ? I mean , if you run 2 time the same process for the same client , is the result correct or is it a problem ? try to make the solution idempotent to overcome retry issue and globally issue that can happen on distribute computing ( include the replay )

© Copyright notes

Related posts

No comments

none
No comments...