Hacker News new | past | comments | ask | show | jobs | submit login
Durable Objects: Easy, Fast, Correct---Choose Three (cloudflare.com)
22 points by jgrahamc on Aug 3, 2021 | hide | past | favorite | 3 comments



Is there any way to start workers that would be guaranteed to be co-located with a specific durable object? This way they would have ultrafast access to the state it manages but not subject to the single-thread limitation.


This is pretty cool.

I in particular like the output gates, I really like that way of handling transaction durability, where you do all the work, but external side-effects are only triggered when the transaction successfully commits. That, combined with the caching makes it really powerful.

There is a case for input gates, I didn't completely follow at first, and I think it might be worth adding as an example to the article. What happens if I do:

  promise = this.storage.get("counter")
  promise2 = fetch("blah")
  await promise2
  await promise
At first I thought this would deadlock, until I looked into the proper description for the input gates:

Any other events will be deferred until such a time as the object is no longer executing JavaScript code and is no longer waiting for any storage operations.

In particular, the "until such a time as the object is no longer executing JavaScript code" - in that case, we would not be running any code, and just return the result of the fetch. If you have two requests doing this, then you may end up with races again. It's akin to your later example with two concurrent storage operations, but in this case there is only one read.


Great read! Maybe it will soon be possible to have a full-stack Cloudflare setup? User management and ACL is still a bit tricky.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: