1

I am trying to build a realtime bid matching engine, where the bid matching logic resides inside a firebase cloud function, and i want the cloud function to have only one instance running at any point of time to prevent data contentions condition.

The idea is that for for every new bid, i create a new google cloud task, but at the same time the new task should be dispatched, only when the the previous task is completed.

Regards Suman

Suman Mondal
  • 47
  • 1
  • 6

1 Answers1

1

You can use the Cloud Task rate limit feature on your task queue. Set it to 1 to dispatch only one task at a time.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
  • 1
    Thanks. So if i set MAX_RUNNING parameter as 1, then only one task will be executed and the next task will be executed on completion of the running task. This is what i expected. Let me try. – Suman Mondal Jan 18 '22 at 09:05
  • @SumanMondal Cloud Tasks is an asynchronous service, so while you can control the dispatch rate and the number of task run concurrently, you can't guarantee that the previous task will reliably complete before you dispatch the next one (at least not using a single queue). – TheAddonDepot Jun 04 '23 at 15:11