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

    DanTheGoodman

    01/28/2023, 1:54 AM
    What's a typical latency of using
    idFromName
    ? I know it has to do a "round the world" lookup which sounds expensive, especially when I could be doing up to 500 of them concurrently in my app im building now lol (plz ping)
  • k

    kenton

    01/28/2023, 3:37 AM
    The
    idFromName()
    call itself completes instantly. However, when you attempt to send a message to the object, a round-the-world lookup will be needed to figure out its location the first time. This is only needed the first time the object is contacted from a particular colo, then its location should be cached. That initial lookup depends on where you are but will probably take in the low hundreds of milliseconds.
  • g

    GuillaumeLakano

    01/28/2023, 9:37 AM
    Hi, I've read the API documentation and CF Blog posts about DO. But I'm still not understood if it's possible to uses it like a little database. We build an e-commerce website, and we want to store customer's data closes to them for performances and to respect GDPR law. So, customer's data are saved all around the world, OK, but what about the classic back-office administration tool that also permit to list customers ? It's common to have a list with at least columns of firstname / surname, with a pagination system and a search engine to find one specific customer. We can't store a copy of their data close to the admin tool because of the GDPR law. So, to show the listing, we need to run a worker, that call the CF API ( https://developers.cloudflare.com/api/operations/durable-objects-namespace-list-objects ), but it's only return a long list of ids, not the stored attached data (firstname, surname) that we need to show. Do we have to open/run each DO to just get the firstname/surname and to show it in our admin listing tool ? This is also a lost of performances/money if we have to do that. This could be useful to have at least a metadata field attached to DO objects ( similar to KV metadata added one year ago ). Even if one day CF create this metadata field, what about the search tool to find a customer easily ? Do we have to get all the IDs+Metadata in-memory and to filter/parse manualy ? This could be a waste of memory, may be search options inside the metadata could also be supported ? Any developers have already deal with DO for this kind of usage that could explain us how they deal with that ? Thank you so much!
  • d

    Deleted User

    01/28/2023, 10:58 AM
    DO only provides a fundamental building block (key -> value storage) you can use to create typical database functionalities with, e.g. indexing. Past that it's all from scratch or libraries. I myself don't know of any libraries yet.
  • g

    GuillaumeLakano

    01/28/2023, 11:19 AM
    Ok, I suppose, we need to have an index DO in each juridiction, that save only the important metadata of each users of the juridication, then a worker used like a CRUD DB operations could check in each juridication DO indexes the metadata and make the requested searches
  • d

    DanTheGoodman

    01/28/2023, 2:00 PM
    got it, thanks!
  • u

    Unsmart | Tech debt

    01/28/2023, 3:27 PM
    Countries always making things so hard for us devs with these data location restrictions
  • g

    GuillaumeLakano

    01/28/2023, 7:49 PM
    I've not found any pricing about using the CF API ( eg: retrieve the DO objects: https://developers.cloudflare.com/api/operations/durable-objects-namespace-list-objects ), is it free ?
  • h

    HardAtWork

    01/28/2023, 7:50 PM
    Yes, the CF API is free, though note that it is also rate-limited.
  • g

    GuillaumeLakano

    01/28/2023, 7:51 PM
    Thank you @HardAtWork , yes I saw the limit on 5 minutes, but at least it's free
  • s

    SZAGLAM

    01/29/2023, 1:24 AM
    Are IST and ADB in "me" or "eeur" as far as the locationHint is concerned?
  • s

    SZAGLAM

    01/29/2023, 3:56 AM
    Or maybe apac 😅
    Copy code
    json
    {
      "cf": {
        "continent": "AS",
        "colo": "ADB"
      }
    }
  • c

    Chaika

    01/29/2023, 4:05 AM
    Just in case you don't know, not all colos run durable objects. https://where.durableobjects.live/ is a community made project to track them You can see on there IST only uses other colos for DOs, and adb isn't even listed (might be too small for cloudflare health checks, which run that platform) For what it's worth, Based on my own data (just generating a new durable object in each region once a minute), in the past 30 days me/eeur has used ARN, FRA, HAM, MXP, PRG, VIE, and WAW
  • u

    Unsmart | Tech debt

    01/29/2023, 4:07 AM
    ADB does run on load balancer health checks 😛
  • s

    SZAGLAM

    01/29/2023, 4:08 AM
    Awesome info, thank you so much! ADB seems to be new, I started getting routed there recently. I actually have a DO in ADB right now, fyi
  • u

    Unsmart | Tech debt

    01/29/2023, 4:08 AM
    I would highly doubt a new data center could support DOs 🤨
  • c

    Chaika

    01/29/2023, 4:09 AM
    Just in case it's worth double checking, are you basing that off where a worker is executing, or creating a new durable object and checking where it is running Plain Workers are in every colo
  • u

    Unsmart | Tech debt

    01/29/2023, 4:09 AM
    especially given it seems to be a single dc and not an mcp
  • s

    SZAGLAM

    01/29/2023, 4:10 AM
    This is from DO response to the worker using the real-time logs (but maybe something else is happening)
    Copy code
    json
            "tlsVersion": "TLSv1.3",
            "colo": "ADB",
            "timezone": "Europe/Istanbul",
            "edgeRequestKeepAliveStatus": 1,
            "requestPriority": "weight=16;exclusive=0;group=0;group-weight=0",
            "asOrganization": "Turkcell",
            "httpProtocol": "HTTP/2"
  • u

    Unsmart | Tech debt

    01/29/2023, 4:11 AM
    I assume thats the data on your initial request. You would need to actually fetch cloudflare.com/cdn-cgi/trace or something similar in the DO
  • c

    Chaika

    01/29/2023, 4:12 AM
    Could possibility double check by visiting
  • c

    Chaika

    01/29/2023, 4:12 AM
    It says on there, "When you loaded this page from , a worker in Chicago (ORD) created a durable object in Chicago (ORD)."
  • c

    Chaika

    01/29/2023, 4:13 AM
    Weird that durableobjects.live doesn't even have it listed then
  • u

    Unsmart | Tech debt

    01/29/2023, 4:15 AM
    doesnt seem to make many requests... in the last 24 hours I only got 119 requests from ADB when the check should run once a minute
  • u

    Unsmart | Tech debt

    01/29/2023, 4:16 AM
    wtf google just started blocking me saying my router may be compromised as part of the meris ddos botnet 🤔
  • s

    SZAGLAM

    01/29/2023, 4:17 AM
    Thank you so much, all "This page tracks where new durable objects are created; for example, when you loaded this page from undefined, a worker in Izmir (ADB) created a durable object in Frankfurt (FRA)."
  • c

    Chaika

    01/29/2023, 4:19 AM
    If you want to check where the durable object is executing, you can make an http request to https://www.cloudflare.com/cdn-cgi/trace from within the durable object, something like
    Copy code
    javascript
    var colo = await (await fetch("https://www.cloudflare.com/cdn-cgi/trace")).text()).match(/^colo=(.+)/m) as string[])[1]
    (Taken from )
  • c

    Chaika

    01/29/2023, 4:20 AM
    But yea makes sense, adb is probably tiny, workers will run there but DOs don't
  • h

    HardAtWork

    01/29/2023, 11:09 AM
    Thank y'all for reminding me that I need to check why some of the stuff on WDL is borked...
  • t

    Tom Sherman

    01/29/2023, 6:46 PM
    Is there a way to call the same durable object from multiple workers?
1...485486487...567Latest