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

    rodbs

    12/22/2022, 9:29 AM
    Are there any best practices about what data structures to use (or are more efficient) with DO)? thx
  • h

    HardAtWork

    12/22/2022, 9:35 AM
    I mean, the only thing I really have to say is balance. You want to keep as much in memory as possible to be able to query it, but DOs can only store values that are so large
  • r

    rodbs

    12/22/2022, 11:31 AM
    One question regarding pricing. It says in the pricing page:
    2. Duration billing charges for the 128 MB of memory your Durable Object is allocated, regardless of actual usage. If your account creates many instances of a single Durable Object class, Durable Objects may run in the same isolate on the same physical machine and share the 128 MB of memory. These Durable Objects are still billed as if they are allocated a full 128 MB of memory.
    I'm using DO to store user data. If user's are creating instances (small) of the same class , does it mean they will run in the same 128MB (as much as it can fit in) and billed once?
  • r

    rodbs

    12/22/2022, 11:36 AM
    Another question: I understand when a DO finishes all I/O operation, Promsies .... is not active anymore, and then evicted from memory (and not billed)?
    Copy code
    Durable Object lifespan
    A Durable Object remains active until all asynchronous I/O, including Promises, within the Durable Object has resolved.
    But then here it says:
    Copy code
    In-memory state in a Durable Object
    Variables in a Durable Object will maintain state as long as your Durable Object is not evicted from memory. A common pattern is to initialize an object from persistent storage and set instance variables the first time it is accessed. Since future accesses are routed to the same object, it is then possible to return any initialized values without making further calls to persistent storage.
    What does
    to return any initialized values
    mean? how are values kept in memory once the DO is not active anymore?
  • u

    Unsmart | Tech debt

    12/22/2022, 11:54 AM
    Memory and storage aren't the same. You can store up to your account limit (50GB) across many or a single DO. It means any values you retrieve at DO init from storage and set in memory. Values aren't kept in memory when evicted anything you don't save to storage will be gone.
  • b

    Burrito

    12/22/2022, 12:49 PM
    Regarding the 50 GB account limit, how much can you really raise it? Or if I keep needing more would I inevitably have to move to R2 or something else?
  • i

    Isaac McFadyen | YYZ01

    12/22/2022, 12:50 PM
    In this case memory means any variables that are on the DO class, instead of stored in the DO key-value store (which is persistent storage).
  • i

    Isaac McFadyen | YYZ01

    12/22/2022, 12:50 PM
    Like, it can be raised?
  • i

    Isaac McFadyen | YYZ01

    12/22/2022, 12:50 PM
    But not many TB.
  • i

    Isaac McFadyen | YYZ01

    12/22/2022, 12:50 PM
    So depends on the size of your data.
  • i

    Isaac McFadyen | YYZ01

    12/22/2022, 12:50 PM
    I wouldn't even count on a single TB tbh
  • b

    Burrito

    12/22/2022, 12:52 PM
    I see.
  • u

    Unsmart | Tech debt

    12/22/2022, 1:50 PM
    I don't really see any reason they would not give you that much storage šŸ¤” I mean maybe you'll need an ENT contract at that point but
  • b

    Burrito

    12/22/2022, 2:51 PM
    Yeah definitely can’t afford that šŸ˜…
  • u

    Unsmart | Tech debt

    12/22/2022, 2:53 PM
    you could always submit the google form limit increase and see what they say 🤷
  • b

    Burrito

    12/22/2022, 2:53 PM
    I need a strong consistency ā€œread-modify-writeā€ storage for user generated content, using DO storage is the obvious choice but the 50 GB limit is a thing
  • b

    Burrito

    12/22/2022, 2:55 PM
    The second option would be DO doing the modification and writing logic to R2, but DO charges for wall clock time so that’s a bit unfortunate.
  • s

    Skye

    12/22/2022, 2:55 PM
    This sounds like something just R2 might be useful for?
  • s

    Skye

    12/22/2022, 2:55 PM
    it's strongly consistent by design
  • b

    Burrito

    12/22/2022, 2:57 PM
    What if a second request comes in when the previous r-m-w is not yet finished?
  • u

    Unsmart | Tech debt

    12/22/2022, 3:02 PM
    Yeah R2 doesnt have that level of consistency. I would just submit a limit increase and see what happens. Maybe even at 1TB or more you wouldnt need an ENT contract but who knows unless you submit a request 🤷
  • u

    Unsmart | Tech debt

    12/22/2022, 3:03 PM
    But also 50GB still is a lot are you sure you even need more than that?
  • b

    Burrito

    12/22/2022, 3:17 PM
    Nope don’t know how much I actually need, just thinking ahead, I’ll send in a form and see what they say.
  • b

    Burrito

    12/22/2022, 3:20 PM
    In the docs it says something about multiple DOs of the same class can run in the same isolate and share memory, does that mean it’s not a guarantee that each DO will always have 128 MB of memory at its disposal?
  • u

    Unsmart | Tech debt

    12/22/2022, 3:21 PM
    yes but very unlikely because that means 2 DOs have to be created on the exact same server and be active at the same time
  • b

    Burrito

    12/22/2022, 3:23 PM
    I see.
  • b

    Burrito

    12/22/2022, 3:25 PM
    It just hit me that I need the entire object to be in memory to do the r-m-w and that might be a bit of an issue with DO.
  • u

    Unsmart | Tech debt

    12/22/2022, 3:27 PM
    if your object doesnt fit in memory it wont fit in a DO value either so there might be some more problems given that šŸ˜›
  • u

    Unsmart | Tech debt

    12/22/2022, 3:27 PM
    its like 128KB for a value?
  • b

    Burrito

    12/22/2022, 3:31 PM
    Well I could always split it and store into multiple keys.
1...463464465...567Latest