https://discord.cloudflare.com logo
Join Discord
Powered by
# durable-objects
  • m

    MichaelM

    09/06/2021, 10:37 PM
    Wondering about the availability of durable objects in all PoPs? Experiments for me right now in Australia create DOs in Singapore. I remember reading somewhere that supporting all locations was challenging. There was some talk of ephemeral DOs (without the storage) that where locked to a location is something like that still being considered?
  • j

    john.spurlock

    09/06/2021, 10:43 PM
    for current state you can check: https://where.durableobjects.live/
  • a

    aa

    09/06/2021, 10:49 PM
    Thank you!
  • h

    hannes

    09/07/2021, 8:17 AM
    that's so cool! but how does it know the location of DO? I thought we cannot retrieve the colo of a DO?
  • a

    albert

    09/07/2021, 9:28 AM
    You can run
    fetch('https://1.1.1.1/cdn-cgi/trace')
    inside the DO 🙂
  • h

    hannes

    09/07/2021, 9:30 AM
    Nice 😀 that solves one of my potential problems
  • l

    lukeed

    09/07/2021, 8:23 PM
    Hi all, looking for a couple more beta testers of a new Durable Object library that we'll be releasing shortly. Please DM if you're interested. Ideally looking for users who already have DO familiarity & have (or plan to) large workloads and/or synchronization needs
  • r

    raRaRa

    09/07/2021, 9:21 PM
    Cool! What kind of synchronisation?
  • l

    lukeed

    09/07/2021, 9:26 PM
    syncs across objects 🙂
  • j

    justinc

    09/07/2021, 10:05 PM
    Are DOs a good replacement for Ably (realtime websocket channels)? I currently have a Cloudflare worker endpoint and I'm using Ably to mass inform clients to hit the endpoint again to get updated data.
  • a

    Alec

    09/07/2021, 10:24 PM
    If the websocket knows you have updated data why not use that to send the data to the clients?
  • j

    justinc

    09/07/2021, 10:25 PM
    Each client gets back a custom response based on the client's identity
  • j

    justinc

    09/07/2021, 10:26 PM
    Whenever the data changes, the response needs to be recomputed for each client
  • j

    justinc

    09/07/2021, 10:27 PM
    I would prefer to push the recomputed data if I could
  • j

    justinc

    09/07/2021, 10:27 PM
    Instead of making each client re-pull it
  • v

    Vanessa🦩

    09/07/2021, 10:31 PM
    Clients can stay connected to a DO via websocket, yes, just as with Ably. The question is more how would the DO know it needs to inform the clients?
  • j

    justinc

    09/07/2021, 10:33 PM
    Could I not communicate to the DO when new data is available to inform it to update clients?
  • v

    Vanessa🦩

    09/07/2021, 10:33 PM
    If you have a single DO for all clients, sure. Don't know what scale you need.
  • j

    justinc

    09/07/2021, 10:35 PM
    I don't have a good handle on my scale either as I'm still an early product. My scale is my customers's scale, so whatever number of live users they have on their site or app. Right now I don't have scaling bottlenecks in my architecture.
  • j

    justinc

    09/07/2021, 10:37 PM
    Is there an understanding of how DOs can scale?
  • v

    Vanessa🦩

    09/07/2021, 10:44 PM
    DOs scale horizontally, so it's best if the workload is distributed across many of them. Meaning if you can partition your data in a way that each DO only handles a small portion, and each client only connects to one or a few of them. E.g. if each chatroom is a separate DO, you can have an unlimited (almost) number of chatrooms, and each room only needs to be able to handle the clients in that room.
  • j

    justinc

    09/07/2021, 10:45 PM
    Gotcha. My data is partitioned around my customers and the scale per customer is their user base, so I could likely have very large partitions.
  • r

    raRaRa

    09/08/2021, 6:51 AM
    @User Nice, I'm currently doing some syncing, between one Lobby DO and multiple Room DOs. Having to post dummy URLs between DOs is a bit.. annoying, but if this library helps with that then I'd love to try it out 🙂
  • l

    lukeed

    09/08/2021, 6:53 AM
    It helps exactly with that 🙂
  • i

    ItsWendell

    09/08/2021, 10:47 AM
    Here's also a snippet that gives you a bit more details (Based on the code of where.durableobject.live)
    Copy code
    ts
    /**
     * Colo interface from https://speed.cloudflare.com/locations
     */
    export interface Colo {
      iata: string;
      lat?: number;
      lon?: number;
      cca2: string;
      region?: string;
      city: string;
    }
    
    /**
     * Gets the current colo of the worker or durable object.
     */
    export async function getColo(): Promise<Colo> {
      // This endpoint returns an array with all of Cloudflare's network locations.
      const coloUrl = "https://speed.cloudflare.com/locations";
      const res = await fetch(coloUrl);
    
      // Extract the colo which sent us the response. The colo is included in the CF-RAY response header.
      // CF-RAY response header example: 1234567890-AMS
      const parts = res.headers.get("CF-RAY").split("-");
      const colo = parts[parts.length - 1];
    
      const colos: Colo[] = await res.json();
      return colos.find((x) => x.iata === colo);
    }
  • i

    ItsWendell

    09/08/2021, 10:53 AM
    @User a setInterval example in your gist would be great, I can't wrap my head around getting it to work / cancel properly.
  • h

    hannes

    09/08/2021, 11:02 AM
    thanks, that's interesting; wondered how to get all the CF colos eventually, another small problem solved
  • h

    hannes

    09/08/2021, 11:03 AM
    I hope someday someone writes all theses tricks together as a blogpost or a recipe list, there si a lot of tribal knowledge about DOs (of course more docs will help, but they'll never cover all the community knowledge)
  • k

    kristian

    09/08/2021, 4:30 PM
    https://discord.com/channels/595317990191398933/773219443911819284/884896621173813290 bumping this for the morning crowd, also star it to get it in #874704644104941569 please!
  • i

    ItsWendell

    09/08/2021, 4:32 PM
    I took a glance at the readme page, it looks super cool! I'm actually working something quite similar, hope I can find the time this week to play around with it!
1...174175176...567Latest