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

    vans163

    04/04/2021, 2:14 PM
    I was thinking to sidestep it by having the DO open a WS to another DO
  • e

    eidam | SuperSaaS

    04/04/2021, 2:15 PM
    afaik there is only the total storage limit (10GB, account wide), and limit per key (32KiB)
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:15 PM
    You could elevate the "balances" class to not sit under a user, but be 'global'. Then you could address it directly.
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:16 PM
    That would at least half the number of requests incurred.
  • v

    vans163

    04/04/2021, 2:16 PM
    Yea thats what I'm thinking but it's a hack around billing
  • v

    vans163

    04/04/2021, 2:16 PM
    Kinda hacking the software cuz it doesnt fit into a billing model is bleh
  • s

    Subh

    04/04/2021, 2:16 PM
    10GB, which can be extended of course?
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:17 PM
    Not really. Totally valid. Think about how banks would function. Many people can have many accounts. So "account" needs to be a global thing and not just a child of "user".
  • e

    eidam | SuperSaaS

    04/04/2021, 2:17 PM
    10GB is (hard?) limit during the open beta, once GA you will pay for what you use
  • v

    vans163

    04/04/2021, 2:17 PM
    Doing operations like addng/subbing balance needs to be syncrobized
  • v

    vans163

    04/04/2021, 2:17 PM
    If the balance sits in a global DO
  • s

    Subh

    04/04/2021, 2:17 PM
    Perfect!
  • v

    vans163

    04/04/2021, 2:17 PM
    Once there are 100,000 users that dO will slow to a crawl
  • v

    vans163

    04/04/2021, 2:18 PM
    Each user needs there own DO to scale properly
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:18 PM
    Nah, not a single instace. One instance per balance!
  • v

    vans163

    04/04/2021, 2:18 PM
    What do you mean by be global then?
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:21 PM
    So if I'm understanding this correctly, I'd structure your data like this: - "User" DO class - "Account" DO class Each user has their own instance of the
    User
    class, and each account has its own instance of the
    Account
    class, where a
    User
    can have zero, one, (or multiple)
    Accounts
    . If you know the
    Account
    ID with the incoming request, you can just go directly to the account's instance, rather than going through the user instance. If you want to find out which accounts a
    User
    has, you can go to the user's instance and list the account IDs from there.
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:21 PM
    But if User = Account in that it's always a 1-1 relationship, then sure, you could flatten it all into a single DO class.
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:22 PM
    (I enjoy thinking about data layout like this way too much lol)
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:26 PM
    Sorry, "global" was maybe a confusing term. I just meant that Account isn't a descendant of User. Unlike what @User might be planning (depending on how who's authorized to see what albums/posts).
  • v

    vans163

    04/04/2021, 2:26 PM
    I see what you mean, so a users account can be found without hitting the user DO
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:26 PM
    Precisely.
  • v

    vans163

    04/04/2021, 2:27 PM
    I think unsyncronized readonly storage for a DO that can be read without fetching into the DO would solve my problems. Then I can check the balance without fetching into the DO. As well as update/changed events on a DO or KV worker storage
  • v

    vans163

    04/04/2021, 2:27 PM
    Would fix my problems
  • k

    Kevin W - Itty

    04/04/2021, 2:28 PM
    that’s KV for ya...
  • k

    Kevin W - Itty

    04/04/2021, 2:28 PM
    bonus: it’s even faster
  • g

    Greg Brimble | Cloudflare Pages

    04/04/2021, 2:29 PM
    Yeah, absolutely. You could cache the data in KV if you're okay with the balance possibly being wrong. But that's just the CAP theorem. Can't have both.
  • k

    Kevin W - Itty

    04/04/2021, 2:29 PM
    I mean, I absolutely envision using DO tightly w KV for these reasons... but namely best read/user performance when writes (or synchronized reads) aren’t necessary
  • e

    eidam | SuperSaaS

    04/04/2021, 2:31 PM
    Read from DO memory is cheaper than KV read, isnt? 🤔 You dont need to access storage for each read, especially when you are accessing same DO multiple times per minute
  • v

    vans163

    04/04/2021, 2:31 PM
    128MB limit on that memory gotta be careful if its userinput
1...444546...567Latest