Skip to content

Distributed coroutines

A coroutine is a function that can be suspended and later resumed. A durable coroutine is a coroutine that can be suspended and later resume in another process. The original process can crash or be restarted manually, and any durable coroutines that were in flight will be resumed automatically.

Durable coroutine is an answer to critical challenges when building distributed systems and workflows:

  • Idempotency. Creating idempotent operations in a distributed system where operations fail and retry can quickly become challenging. By allowing the program to snapshot the progress of its current execution thread, durable coroutines provide a simple answer to this problem.
  • Durability. Durable coroutines allow the recording of the coroutine‚Äôs state at each yield point. This state can be stored on a highly durable store system, like S3, and be later retrieved to either resume the process or do some introspection.
  • Introspection. The state of the durable coroutines allows for deep introspection and automated observability. Since a durable coroutine records the entire flow of execution, we can instrument any of the application behavior automatically.