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

    Unsmart | Tech debt

    03/30/2023, 2:42 AM
    That's a per value limit not a total limit. You can have an unlimited number of values per object
  • f

    four33

    03/30/2023, 2:43 AM
    oh I see...
  • f

    four33

    03/30/2023, 2:43 AM
    interesting
  • c

    Crazy Rabbit

    03/30/2023, 3:48 PM
    a lot of other alternatives also offers to display top 10 voters per poll. I made some calculations and if I want to store username + amount of votes then DO will only be able to handle around 8000 usernames. Example if I store in DOs:
    Copy code
    json
    {
      "Username1": 3,
      "Username2": 12
    }
  • c

    Crazy Rabbit

    03/30/2023, 3:48 PM
    one solution would be to have a limit for example 100 and as soon as 101 person vote it will remove the one with the least votes from object.
  • c

    Crazy Rabbit

    03/30/2023, 3:49 PM
    but this won't work if for example 500+ people vote in the same day.
  • c

    Crazy Rabbit

    03/30/2023, 3:49 PM
    So it would remove the ones that still have 1 month left to do to vote and maybe beat others and enter the top 100 voters.
  • c

    Crazy Rabbit

    03/30/2023, 3:52 PM
    but storing each username under the different key would just be a pain as I would need to read thousands of keys just to get usernames that have the most votes.
  • u

    Unsmart | Tech debt

    03/30/2023, 3:52 PM
    not really you just store their number of votes in the key so that they can be listed in the order of most votes first
  • c

    Crazy Rabbit

    03/30/2023, 3:55 PM
    wou list actually return the values.
  • u

    Unsmart | Tech debt

    03/30/2023, 3:56 PM
    yes
  • c

    Crazy Rabbit

    03/30/2023, 4:02 PM
    Feels nice that all problems just disappeared in a second.
  • t

    themetanull

    03/30/2023, 5:59 PM
    When we talk from DO-A to another DO-B, is there any advantage if we initialize the stub once during the DO instance creation (or during re-instantiation) in the constructor? Of course, I'd retry if fetches fail. But I'd like to think connecting from a DO to another DO has this advantage compared to connecting from a worker to a DO (where each worker request would need to instantiate the stub every time)
  • a

    avi

    03/30/2023, 8:23 PM
    is there any way to delete all durable object storage?
  • a

    avi

    03/30/2023, 8:23 PM
    like across all durable objects in a given namespace
  • h

    HardAtWork

    03/30/2023, 8:28 PM
    Not without deleting the namespace
  • a

    avi

    03/30/2023, 8:28 PM
    i see, and deleting the namespace also deletes all objects in it?
  • h

    HardAtWork

    03/30/2023, 8:29 PM
    Yes
  • a

    avi

    03/30/2023, 8:32 PM
    got it, thanks.
  • a

    avi

    03/30/2023, 8:32 PM
    another question — is the workers.dev domain suitable for production use?
  • a

    avi

    03/30/2023, 8:32 PM
    the 'dev' tld makes me think it's only for development
  • a

    avi

    03/30/2023, 8:32 PM
    can't find any documentation about it
  • u

    Unsmart | Tech debt

    03/30/2023, 8:37 PM
    it can be but generally you should always use custom domains for more control
  • a

    avi

    03/30/2023, 8:41 PM
    for sure
  • a

    avi

    03/30/2023, 8:41 PM
    i'm trying to wrap my head around how i'm going to manage the # of DO instances i'm going to have...
  • a

    avi

    03/30/2023, 8:41 PM
    i'm gonna have tens of thousands
  • a

    avi

    03/30/2023, 8:41 PM
    and there's no clear way to manage them
  • c

    ckoeninger

    03/30/2023, 9:31 PM
    generally speaking you'll need to iterate through DOs using https://developers.cloudflare.com/api/operations/durable-objects-namespace-list-objects
  • c

    ckoeninger

    03/30/2023, 9:32 PM
    can you say more about what management operations you'd be doing besides deletion?
  • a

    avi

    03/30/2023, 9:49 PM
    sure, my use-case is i'm use DOs to serve as the gameservers for an online web game i'm building. i don't really need persistence, just stateful routing to on-demand compute over websockets. 1 DO = 1 "room" for the game. a room only lasts a few minutes, and then once everyone disconnects, i don't want it around — i actually want to recycle the room ID.
1...530531532...567Latest