Live data from Hacker News

Workers Durable Objects Beta: A New Approach to Stateful Serverless

blog.cloudflare.com

31–40 of 98 posts

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#31

One thing I am not sure, maybe I missed something in the blog but will there be always one instance of this object or can there be multiple?

Durable Objects are globally unique, so it's guaranteed that there's just one instance with a given id.

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#32
post #26
post #20

Interesting, i didn't see how security works? Is there backpressure on message senders? Any ordering guarantees? Are messages queued so activated objects can reconstruct state? Can passivation warmth be controlled? Can objects support multiple threads? Can objects move? Failover?

Great questions. > how security works? Messages can only be sent to Durable Objects from other Workers. To send a message, you must configure the sending Worker with a "Durable Object Namespace Binding". Currently, we only permit workers on the same account to bind to a namespace. Without the binding, there's no way to talk to Durable Objects in that namespace. > Is there backpressure on message senders? Currently, t…

> Can passivation warmth be controlled?

A variant of the cold start problem. How long after all the messages for an object drain is it passivated? Can you keep it pinned in memory?

Another question. Can objects contain relationships that are themselves references to other Durable Objects? Say a simple reference, or a list, or DAGs?

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#33
post #31

One thing I am not sure, maybe I missed something in the blog but will there be always one instance of this object or can there be multiple?

Durable Objects are globally unique, so it's guaranteed that there's just one instance with a given id.

Right, that's what I got from the Unique explanation in the doc. What I am confused about is this part:

With Durable Objects, you instead design your storage model to match your application's logical data model. For example, a document editor would have an object for each document, while a chat app would have an object for each chat. There is no problem creating millions or billions of objects, as each object has minimal overhead.

What does it mean that a document editor will have an object for each document? Will I have to create a new UDO each time a new document is created?

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#35
Some wanky theory about computing and the design of programs follows. (Not out of scope considering the philosophical underpinnings of this product and the "edge", etc.)

The chat demo says:

> With the introduction of modules, we're experimenting with allowing text/data blobs to be uploaded and exposed as synthetic modules. We uploaded `chat.html` as a module of type `application/octet-stream`, i.e. just a byte blob. So when we import it as `HTML` here, we get the HTML content as an `ArrayBuffer`[...]

    import HTML from "chat.html";
I've thought a lot about this for the work that I've been doing. From an ergonomics standpoint, it's really attractive, and the only other viable alternatives are (a) dynamically reading the asset, or (b) settling on using some wrapper pattern so the original asset can be represented in the host language, e.g.:

    export const IMAGE_DATA =
      "iVBORw0KGgoAAAANSUhEUgAAAD8AAAA/..." +
      "..."

    export const HTML = `
      
    `;
... which is much less attractive than the "import" way.

Ultimately I ended up going with something closer to the latter, and there wasn't even any reluctance about it on my part by the time I made the decision—I was pretty enthusiastic after having an insight verging on a minor epiphany.

I'd been conflicted around the same time also about representing "aliens" (cf Bracha) from other languages and integrating with them. I slapped my head after realizing that the entire reason for my uneasiness about the latter "data islands" approach was because I wasn't truly embracing objects and that these two problems (foreign integration and foreign representation) were very closely related. Usually you don't actually want `HTML`, for example, and focusing on it is missing the forest for the trees. I.e., forget whatever you were planning with your intention to leave it to the caller/importer to define procedures for operating on this inert data. Make it a class that can be instantiated as an object that knows things about itself (e.g. the mimetype) and that you can send messages to, because that's what your program really wants it to be, anyway. Once you're at that point, the "wrapper" approach is much more palatable, because it's really not even a wrapper anymore.

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#36
post #31

Earlier quoted context omitted.

Durable Objects are globally unique, so it's guaranteed that there's just one instance with a given id.

Right, that's what I got from the Unique explanation in the doc. What I am confused about is this part: With Durable Objects, you instead design your storage model to match your application's logical data model. For example, a document editor would have an object for each document, while a chat app would have an object for each chat. There is no problem creating millions or billions of objects, as each object has min…

It means that you'd use a different ID to access each document. Each document's Durable Object would run the same code as part of the same namespace of Durable Objects, but have their own in-memory and durable state. Check out the docs for a bit more context: https://developers.cloudflare.com/workers/learning/using-dur...

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#37
> I'm going to be honest: naming this product was hard, because it's not quite like any other cloud technology that is widely-used today.

On a superficial skim it looks like a tuple space; they were heavily researched in the 80s and 90s. JavaSpaces emerged in the late 90s but never took off.

Scala folks are keen on Actor models (Lightbend have been using the term "Stateful Serverless" for a while now), as are Erlang and Elixir folks.

I guess the key here is "widely-used".

Edit: this sounds even more arrogant than I intended. Sorry. I just feel bad for tuple space researchers (including my Honours supervisor). They laboured mightily in the 80s and 90s and their reward was to be largely ignored by industry.

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#38

I’m wondering what sort of durability guarantees there are in case of an outage? It seems like replicating durable storage would add latency? Is there going to be Jepsen testing for this?

Storage is replicated across a handful of nearby sites. It does add some latency to writes, but that's preferable to Objects being offline or lost in the case of hardware or network failures.

There's no Jepsen testing in the works at the moment, but we'll see if it makes sense in the future.

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#39

Earlier quoted context omitted.

Right, that's what I got from the Unique explanation in the doc. What I am confused about is this part: With Durable Objects, you instead design your storage model to match your application's logical data model. For example, a document editor would have an object for each document, while a chat app would have an object for each chat. There is no problem creating millions or billions of objects, as each object has min…

It means that you'd use a different ID to access each document. Each document's Durable Object would run the same code as part of the same namespace of Durable Objects, but have their own in-memory and durable state. Check out the docs for a bit more context: https://developers.cloudflare.com/workers/learning/using-dur...

I am still a bit confused. Will this ID be different from the object id of for accessing the Durable Object, essentially in this case we would be using the Durable Object as a key-value storage? Or is it like the Namespace is separate from the Durable Object and each Namespace can have multiple objects of the same class under?

Edit: I think I get it now. Sorry I misunderstood that each Durable Object is like a singleton for the class you define. Its the other way around, you have the definition and namespace and then you can create a new object from those whenever you need it and this one would unique and accessible across all workers.

Re: Workers Durable Objects Beta: A New Approach to Stateful Serverless

#40
post #29

If I'm getting this right, it's essentially immediately consistent distributed state for workers. They could have called it simply "Workers State" :) Now in all seriousness, this is super impressive. Congrats to the CF team!

Heh, that is actually a name we considered, and as a name on its own, I like it a lot.

But we also needed a name for the individual instances. We also found that the people who "got" the product were the ones who thought of it in terms of object-oriented programming (an object is an instance of a class). So we ended up gravitated towards "objects".

But I dunno, naming is hard. "Workers State" may in fact have been a better name!

Post reply on HN