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

    Colin

    05/19/2023, 5:39 PM
    mine is showing
    112
    right now when i'd expect like >100k if it included messages
  • u

    Unsmart | Tech debt

    05/19/2023, 5:40 PM
    Yes compute > total requests... the 24 hour view can be pretty delayed check the other options. 30 minutes updates the fastest
  • u

    Unsmart | Tech debt

    05/19/2023, 5:40 PM
    24 hour is the only one that doesnt show my request volume at the moment 🤷
  • c

    Colin

    05/19/2023, 5:40 PM
    yeah I was checking it, it was last night so it's been at least 8 hours now
  • c

    Colin

    05/19/2023, 5:41 PM
    i'd think(?) that's enough time, i'm not sure how fast it updates
  • c

    ckoeninger

    05/19/2023, 6:22 PM
    metrics summary definitely shows DO websocket messages as requests for me
  • c

    ckoeninger

    05/19/2023, 6:22 PM
    DM me your account id if you want me to take a look
  • c

    Colin

    05/19/2023, 6:51 PM
    that'd be great, just added you on disc
  • c

    ckoeninger

    05/19/2023, 7:20 PM
    sorry for saying it was definitely showing in my dashboard - that was for a DO using the as yet unpublished websocket hibernation api (see pinned messages). I can repro on the current websocket api, filing a bug
  • u

    Unsmart | Tech debt

    05/19/2023, 7:21 PM
    Oh mine was using the hibernation api too
  • w

    Wallacy

    05/19/2023, 7:41 PM
    Im little out of the loop... Is the automatic migration of DO be part of the smart placement?
  • c

    Colin

    05/19/2023, 8:00 PM
    no worries, thanks for looking
  • c

    Colin

    05/19/2023, 8:01 PM
    just to confirm, this is a dashboard bug and they 100% do count as billable requests, correct?
  • c

    ckoeninger

    05/19/2023, 8:10 PM
    they are billable requests correct
  • c

    ckoeninger

    05/19/2023, 8:11 PM
    there is no current expected timeframe for automatic migration of DO (aside from the existing failover behavior)
  • k

    Kai

    05/19/2023, 11:44 PM
    Looks like there are new APIs for websocket hibernation? Haven't seen this anywhere yet, but looks like they are in the TS typings & the chatroom example has an open branch with them. Do they work yet? Is it just testing?
  • u

    Unsmart | Tech debt

    05/19/2023, 11:45 PM
    I tried it and it did work but theres not been an official release so I assume it can break at any time and shouldnt be used
  • u

    Unsmart | Tech debt

    05/19/2023, 11:46 PM
    the docs for it are pinned here tho 🤷
  • k

    Kai

    05/19/2023, 11:49 PM
    I mean it's super cool, I was just about to rework the outdated logic for a websocket gateway I have. Might just try what happens if I just give every user their own DO & make it hibernate... Seems like it might push costs down a lot, but requires a different setup
  • k

    Kai

    05/20/2023, 12:04 AM
    Looking at the preview pricing right now, if I understand this correctly, there will now only be billing for one request / message + wall time for the time it takes to process the request, exactly the same HTTP requests are handled, just I get to keep some state? It seems like this would end up cutting costs significantly, I only use the WS to relay to a messaging system, seems like this will be incredibly cheap?
  • k

    Kai

    05/20/2023, 12:10 AM
    If 100 Durable Objects each had a single WebSocket connection established to each of them, which sent one message a second for a month, and the messages take 10ms each to process (each DO is active for 1% of the month) Total = ~$38.73 USD + Minimum $5/mo usage = $43.73 ?? - 100 requests to establish the WebSockets. - 1 message per second * 100 connections * 60 seconds * 60 minutes * 24 hours * 30 days = 259,200,000 requests (259.2 million requests - included 1 million requests) x $0.15 / 1,000,000 = $38.73 - 100 Durable Objects * 0.6 seconds * 60 minutes * 24 hours * 30 days = 2,592,000 seconds 2,592,000 seconds * 128 MB / 1 GB = 331,776 GB-s => 400,000 GB-s included
  • k

    Kai

    05/20/2023, 12:11 AM
    Maybe my math is wrong, but this seems pretty reasonable and super cheap
  • ```
    m

    Matt

    05/20/2023, 3:25 AM
    Copy code
    const MINUTES = 60 * 1000
    
    export class NanoID {
      constructor(state, env) {
        this.state = state
      }
    
      async fetch() {
        let value = await this.state.storage.get("value")
        if (!value) {
          value = nanoid()
          await this.state.storage.put("value", value)
          this.storage.setAlarm(Date.now() + 2 * MINUTES)
        }
        return new Response(value)
      }
    
      async alarm() {
        this.state.storage.deleteAll()
      }
    }
    Does this look okay?
    z
    d
    • 3
    • 2
  • w

    Wallacy

    05/20/2023, 4:23 AM
    Thats awesome! I did i custom logic to able to scale my WS without break my DO. I was able to put 1K WS sessions per DO (but i only use 100 in production)! But not only the hibernation thing can handle 32,768 WebSockets connected per Durable Object instance, but will finally not bill the time that WS is just idle! Thanks god. I do not plan use more than 1K connections btw, but my WS are doing nothing for 95% of the time! I was about to move that logic to a VM in another place.
  • h

    hanpolo

    05/21/2023, 12:21 AM
    Can I access R2 from a durable object?
  • h

    hanpolo

    05/21/2023, 12:22 AM
    If so, can I just set the bindings in the wrangler.toml file of the DO worker?
  • s

    sathoro

    05/21/2023, 4:29 AM
    Yes
  • l

    Lloyd

    05/21/2023, 2:01 PM
    I'm trying to use durable objects, Is there any way bind objects to workers with cloudflare dashboard like env setting? is wrangler necessary?
  • q

    Quân Hoàng

    05/21/2023, 4:20 PM
    hi guys, i wanna implement presence server features using workers, say if client A connected to worker A and client B connected to worker B, when client A online i wanna broadcast message to client B, but since client B is connected to different worker other than client A, i would have to use durable objects to store websocket connections right? or using message queue here is a better idea? thanks for any comment
  • q

    Quân Hoàng

    05/21/2023, 4:20 PM
    both clients are connected to workers using websocket
1...560561562...567Latest