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

    Greylock

    07/01/2021, 3:04 AM
    with round trip to the worker and back to my client it takes like 40ms in total
  • g

    Greylock

    07/01/2021, 3:05 AM
    and the worker itself usually responds within 20ms for a very simple response, but for SSR and all the other route matching its roughly ~30ms on average
  • g

    Greylock

    07/01/2021, 3:05 AM
    which is leaving me wondering whether I should just check auth on every single call, or if I should still use JWTs or something
  • g

    Greylock

    07/01/2021, 3:05 AM
    I guess id still need to check the sig of the JWT and keep it in the KV
  • g

    Greylock

    07/01/2021, 3:05 AM
    so I might as well just query the users DO every call and check if their token is valid
  • w

    Wallacy

    07/01/2021, 3:08 AM
    I’m using the KV for my tokens because the DO is very slow on my city. The round trip is 180ms ;
  • w

    Wallacy

    07/01/2021, 3:12 AM
    But I usually write on KV using DO + waituntill(), in this case I don’t need to wait the KV write and still get the advantages of the DO as “Actor” …
  • g

    Greylock

    07/01/2021, 3:15 AM
    Hmm that’s interesting
  • g

    Greylock

    07/01/2021, 3:15 AM
    I might use KV for the auth tokens but I’m not sure
  • g

    Greylock

    07/01/2021, 3:15 AM
    I wouldn’t consider 180 very slow, that’s still like half of what aws lambda can offer
  • g

    Greylock

    07/01/2021, 3:40 AM
    with expiring KV keys, is there a way to get the expiration date of it?
  • g

    Greylock

    07/01/2021, 3:41 AM
    so like, I can tell if its about to expire and refresh it?
  • z

    zifera

    07/01/2021, 8:41 AM
    Is there a way to access DO without a fetch request? If you just want to do internal stuff, not from the user/client?
  • z

    zifera

    07/01/2021, 8:53 AM
    Or do you have to create a "fake" request if its not relevant to the actual incoming request
  • d

    Deebster

    07/01/2021, 9:15 AM
    after the initial creation, is there any benefit to caching the id or is using idFromName() pretty much/exactly as fast?
  • m

    MrHalzy

    07/01/2021, 11:48 AM
    You would call
    deleteAll
    from within the durable object.
  • b

    brett

    07/01/2021, 1:38 PM
    Where are you located, and are you using
    idFromName
    or
    newUniqueId
    ?
  • b

    brett

    07/01/2021, 1:39 PM
    No, the only API currently available is HTTP. I'm not sure what you mean by internal, you can design your own URL Path / HTTP Method routing inside of the DO
  • b

    brett

    07/01/2021, 1:41 PM
    Each Cloudflare colo will cache the true location of a named DO the first time it is accessed from that location.
  • b

    brett

    07/01/2021, 1:43 PM
    The
    list
    method will return expiration info, or you could (redundantly) put your own expiration info in metadata and use
    getWithMetadata
  • k

    kenton

    07/01/2021, 2:20 PM
    To be clear,
    idFromName()
    always returns instantly, it computes the ID without doing any network communications. The delay comes when you access the object. The first time it is accessed, the system has to check if the same ID has already been used anywhere else in the world, which can be slow. The information is then cached in the calling colo, so subsequent requests from the same colo will use the cached information and will be faster. Though eventually the cache may be evicted, of course.
  • d

    Deebster

    07/01/2021, 2:39 PM
    Yup, that makes perfect sense. Out of interest, when you do
    DurableObjectNamespace.get(id): DurableObjectStub
    , is your implementation something like you fork off a getOrCreateDO() call and then return the stub? Or does that bit get done when you do the first fetch()?
  • k

    kenton

    07/01/2021, 3:11 PM
    When you do get(id), we send out the network request to find the object. We can immediately return a stub because we use Cap'n Proto under the hood, which implements something called "Promise Pipelining". When you call fetch(), we can send the fetch message even if the initial lookup hasn't completed yet, by sending it as a pipelined request. https://capnproto.org/rpc.html
  • w

    Wallacy

    07/01/2021, 3:27 PM
    idFromName ; Brasilia - Brazil
  • b

    brett

    07/01/2021, 3:30 PM
    Good to know. You are right that we still need to enable DOs in colos closer to you.
  • w

    Wallacy

    07/01/2021, 3:41 PM
    @User Any plans to make the durable to "auto store" properties like the "itty-durable" project? I mean, you can get rid the entire fetch inside of the durable and map the properties/actions calls outside the JS to performance gain. Im not talking about the save the current memory state, only the properties of the durable class (like the itty-durable project). You can also optimize the read operation if the DO is inside of the same datacenter.
  • g

    Greylock

    07/01/2021, 3:43 PM
    But does that delete the durable object itself?
  • w

    Wallacy

    07/01/2021, 4:06 PM
    Just the storage
  • g

    Greylock

    07/01/2021, 4:07 PM
    ah
  • g

    Greylock

    07/01/2021, 4:07 PM
    but it effectively removes it
1...119120121...567Latest