https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • z

    zszszsz

    02/24/2023, 12:55 AM
    stackoverflow is not as helpful as it seems hmm
  • l

    Louis DCK

    02/24/2023, 7:22 AM
    How long can a worker run before it time outs?
  • h

    HardAtWork

    02/24/2023, 8:33 AM
    Theoretically indefinitely, though after 30 seconds, it has a higher chance of spontaneous eviction
  • z

    zszszsz

    02/24/2023, 8:52 AM
    30s sounds short.
  • z

    zszszsz

    02/24/2023, 8:53 AM
    So it is not suitable for long lasting connections
  • l

    Louis DCK

    02/24/2023, 9:01 AM
    Where do you get this 30s from or is that personal experience?
  • h

    HardAtWork

    02/24/2023, 9:04 AM
    From some engineers I've talked to. Trying to figure out if it is on the docs.
  • h

    HardAtWork

    02/24/2023, 9:05 AM
    Here we go:
  • h

    HardAtWork

    02/24/2023, 9:05 AM
    Is this for some kind of database connection?
  • z

    zszszsz

    02/24/2023, 9:14 AM
    They say durable objects can do long connections and ws ?
  • h

    HardAtWork

    02/24/2023, 9:15 AM
    Yes. First of all because every time it receives a WebSocket event the timer resets, but also because again, you aren't force-evicted after 30 seconds, you just have a higher chance of it occuring.
  • z

    zszszsz

    02/24/2023, 9:18 AM
    Does that mean, a normal worker can actually do the same thing if there is no cpu time limit ?
  • h

    HardAtWork

    02/24/2023, 9:20 AM
    Yes. A normal Worker can run for multiple minutes, though we recommend structuring your app in a way it can recover gracefully if the Worker is spontaneously aborted after the 30 seconds have elapsed.
  • z

    zszszsz

    02/24/2023, 9:21 AM
    So what about DO, would it handle long connections better ?
  • h

    HardAtWork

    02/24/2023, 9:22 AM
    In terms of just the connection, not specifically. One benefit of a DO though is the fact that, if you are running a job over a WebSocket(as an example), and it may take minutes/hours to respond, you can ping to periodically wake it up with DO Alarms, and store any connection-specific state in DO Storage.
  • z

    zszszsz

    02/24/2023, 9:33 AM
    Thanks for the knowledge. It is surprising to know that a normal worker can be indeed good.
  • z

    zszszsz

    02/24/2023, 9:35 AM
    And maybe
    A Durable Object is given 30 seconds of additional CPU time for every request it processes, including WebSocket messages.
  • z

    zszszsz

    02/24/2023, 9:35 AM
    Every incoming message brings and extra 30s CPU time..
  • a

    anurag

    02/24/2023, 9:51 AM
    Is there a way to increase the CPU limits? đź«  Can I pay extra, I'm already on a Pay-as-you-go plan.
  • a

    anurag

    02/24/2023, 9:59 AM
    I'm hitting these limits. I reduced the CPU limit errors from > 500 to 1-2 but still, it should be 0.
  • k

    kian

    02/24/2023, 10:01 AM
    Bundled has 50ms and Unbound has 30 seconds
  • k

    kian

    02/24/2023, 10:02 AM
    I'm not aware of anything higher than that
  • z

    zszszsz

    02/24/2023, 10:08 AM
    maybe, divide individual computation into small pieces ?
  • z

    zszszsz

    02/24/2023, 10:09 AM
    That 50ms must be per-request ya ?
  • a

    anurag

    02/24/2023, 10:10 AM
    Yes, it's one big call, which internally makes calls to KV and 3 third-party APIs.
  • z

    zszszsz

    02/24/2023, 10:11 AM
    But the thing is not what it calls, it is the huge amount of computation is it
  • z

    zszszsz

    02/24/2023, 10:12 AM
    May I ask
  • z

    zszszsz

    02/24/2023, 10:12 AM
    https://developers.cloudflare.com/workers/learning/metrics-and-analytics/#cpu-time-per-execution
  • a

    anurag

    02/24/2023, 10:13 AM
    oh, I have a weird logic with while loop. let me check that, maybe it's infinitely getting called
  • z

    zszszsz

    02/24/2023, 10:13 AM
    "mechanism in the Workers runtime that allows rollover CPU time for requests below the CPU limit"
1...230323042305...2509Latest