iwf icon indicating copy to clipboard operation
iwf copied to clipboard

Use external storage for large data attributes [Large Feature]

Open longquanzheng opened this issue 1 year ago • 4 comments

When exceeding the threshold (configurable, e.g. 100KB) for a data attribute, iWF can use others like S3 for storing the data attributes instead of writing into Temporal history. (only storing the keys and the S3 objectIDs)

By storing keys and S3 objectIDs in Temporal history, IWF server will load from S3 before sending to application, and write to S3 for updates. For optimization, server could also load from S3 lazily when application tried to read it.

This is possible because iWF server workflow never really read the value of the DAs -- they are transparent to iWF server.

By offloading the large data attributes to S3, it's much easier for users to deal with large datasets, and more cost effective on using Cadence/Temporal.

longquanzheng avatar Dec 05 '24 22:12 longquanzheng

probably we don’t need to store s3 object id at all. The id can just be based on workflowID+attribueKey

so in the history, we only store the DA is stored somewhere— a flag like “s3” .

longquanzheng avatar Dec 18 '24 19:12 longquanzheng

Potentially, it can use local disk as cache for large DAs

longquanzheng avatar Mar 11 '25 19:03 longquanzheng

probably we don’t need to store s3 object id at all. The id can just be based on workflowID+attribueKey

so in the history, we only store the DA is stored somewhere— a flag like “s3” .

using attribute key as object id(aka object path in s3)will not work for two reasons:

  1. Reset. When a workflow execution reset to previous point, the DA will not be reset. Eg a workflow has a DA to count for each state execution, after 10 times the counter is 10. Now reset to 2 to recount , it will still be 10 and then finally get 18.
  2. Edge cases for failure in distributed system. There is no way to have atomic operations between replacing the value and successfully complete a state api execution or RPC execution , in some cases (timeout , server side errors ) the value will be updated but still return error can cause retry. But when retrying, the value has been changed can cause incorrect results. For example, a state api will increase a counter by one , when it update from 0 to 1 to external storage, it got a timeout , so state api will retry , and then it will get 1 to increase to 2, so on so forth . The value will be changed during the state api retry.

longquanzheng avatar Apr 23 '25 20:04 longquanzheng

@longquanzheng I looked through the codebase against this issue. The S3 offloading with UUID-per-write keys, threshold config, and cleanup cron is all in place already.

Two things from your comments that seem open still:

  1. DA rollback on reset - DAs in Memo/S3 don't get restored when a workflow resets. Probably needs a design discussion first.
  2. Local disk cache - No local filesystem backend behind BlobStore yet.

Happy to pick either of these up. Any preference?

pradhankukiran avatar Mar 25 '26 11:03 pradhankukiran