4 ms·
I love using Cloudflare for my projects, but something about Durable Objects just scares me so much. I feel like an application like collaborative editing woul
by eddd-ddde 3y ago
I love using Cloudflare for my projects, but something about Durable Objects just scares me so much.
I feel like an application like collaborative editing would send so much requests that billing would have to be insane, right? Even for my hobby size projects which I would like to publish for fun, terrify me with possible usage costs.
Their hibernation web socket thingy is great, but the real thing that scares me is the overall web socket message cost.
- kentonv 3y agoFWIW yesterday we announced that WebSocket messages are now billed at 1/20 of a request, rather than a full request. It was kind of buried in this omnibus blog: https://blog.cloudflare.com/workers-production-safety https://blog.cloudflare.com/workers-production-safety
- ftigis 3y agoIs this the better pricing y'all are figuring out that's been dangled since the launch of Durable Objects + WebSocket on Workers? Oh and somehow I missed the Hibernation API announcement. Paying for idle but connected time is what made me nope out of trying it out.
- eddd-ddde 3y agoOh I totally missed that, thanks for making me aware of it. Edit: Oh wow, I totally missed the rate limiter thing as well. Just last week I was implementing my own using DO. It's great to see this developments.
- Sai_ 3y agoYour clients control the number of messages they exchange with each other via the DO. You still have to protect the DO through some sort of auth and/or rate limits. Don’t see how any of these issues are unique to DOs.
- jaflo 3y agoWhen I took a look at using DO last time I decided against using them because you had to pay for the duration your clients are connected to them when using WebSockets. As far as I understood it’s not execution duration but flat out how long your clients are connected. You’ll burn through seconds quickly that way. I decided to go with a polling mechanism instead.
- ec109685 3y agoThey have hibernating durable objects now that don’t charge unless there is a request through them: https://developers.cloudflare.com/durable-objects/api/websockets/ https://developers.cloudflare.com/durable-objects/api/websoc...
- jaflo 3y agoOh that’s neat! I’m not sure if it didn’t exist or if I didn’t find this last time. Looks like this would address the problem.
- eddd-ddde 3y agoMy issue was that a single message, be it 4 bytes, was essentially billed the same as a 20Mb request. Didn't make too much sense to me. If I have to think about batching messages to decrease costs even tho my overall transport and execution would be the same, I feel like that's an issue on the platform somehow.
- _factor 3y agoIf you’re concerned, another alternative is to use WebRTC for peer to peer connections. Bypass the server entirely and use it only for signaling. https://github.com/dmotz/trystero https://github.com/dmotz/trystero