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

    Neiki

    05/06/2023, 9:19 PM
    so my function is f.ex that i upload an file threw an "api" that is one of my worker to another webpage f.ex github, would that work? i mean it uses the cpu so the cpu would extend no? sorry
  • k

    kian

    05/06/2023, 9:19 PM
    Depends if that's using up CPU.
  • k

    kian

    05/06/2023, 9:19 PM
    Just passing a request body doesn't.
  • n

    Neiki

    05/06/2023, 9:20 PM
    okay so if i use f.ex axios in my worker and upload an file to an api like github it would work? it would take like 10 seconds website upload file > worker uploads file to github
  • n

    Neiki

    05/06/2023, 9:20 PM
    like that
  • n

    Neiki

    05/06/2023, 9:21 PM
    sorry for the confusing here ... i switched recently to cloudflare pages / workers and i didnt understood the workers CPU limit of 10ms
  • n

    Neiki

    05/06/2023, 9:21 PM
    it got me confused because of my use case if that uses CPU or not i mean it uploads a file to github f.ex i mean does that use CPU or not lol
  • n

    Neiki

    05/06/2023, 9:33 PM
    - My question: i have an api webpage f.ex "api.mywebsite.com" I have an file uploader on "mywebsite.com/upload" i upload an file to that upload website that sends the file to my api (the worker) and on that worker it uploads (post request) to github to my repo f.ex will that work or would that extend the CPU limit of 10ms with my free plan, i mean it does requests and u know and that will take f.ex more than 10 seconds or maybe 60 seconds but that should be no problem because workers can run long as i know. sorry i am confused what the "CPU limit" means.
  • b

    biscuit

    05/07/2023, 12:37 AM
    Should i try to test out tensorflow.js on a cloudflare worker or is there some wall I might hit? I wouldn't want to spend hours setting up everything to eventually figure out its not possible.
  • k

    kian

    05/07/2023, 12:38 AM
    It'll probably be a lot of pain to get it working and run into Workers limits (CPU time, memory, etc) even if you do
  • k

    kian

    05/07/2023, 12:39 AM
    https://twitter.com/wongmjane/status/1653865241795502081 might be interesting for your use-case, but I have no idea when it'll be available
  • d

    dkfdkdodkms

    05/07/2023, 1:51 AM
    i am looking to identify if a worker was invoked on the same machine or location (the level where workers have access to the same global scope), via some sort of id. this way i can use that id to store information in a kv. the next time the worker is invoked, i can check for the existence of the kv with that id. is there a way to do this?
  • k

    kian

    05/07/2023, 1:52 AM
    You can throw a variable in the global scope, that's about it
  • d

    dkfdkdodkms

    05/07/2023, 1:53 AM
    but then the worker "reboots", and there goes the id
  • k

    kian

    05/07/2023, 1:53 AM
    Sure, but you asked about the level where they have access to the same global scope.
  • k

    kian

    05/07/2023, 1:53 AM
    if a Worker is evicted and comes back, it isn't the same global scope.
  • d

    dkfdkdodkms

    05/07/2023, 1:54 AM
    got that, but what i am thinking of doing is creating the kv in the global scope given the id (if it hasn't been created already). Then when the worker goes and comes back again, i can again check the existence of that kv in the global scope, and if it is there use it, otherwise create it
  • d

    dkfdkdodkms

    05/07/2023, 1:55 AM
    so there is essentially a way to persist data between reboots for a particular location
  • k

    kian

    05/07/2023, 1:55 AM
    That's not possible with Workers, you'd need to use KV/DOs and just insert location information into the key
  • d

    dkfdkdodkms

    05/07/2023, 1:56 AM
    not possible, because that id doesn't exist or is inaccessible?
  • k

    kian

    05/07/2023, 1:57 AM
    I don't understand what you mean - you can't persist data between reboots without an external service.
  • k

    kian

    05/07/2023, 1:57 AM
    You could make an ID for the location, but that's it - anything you stored is gone after an eviction.
  • d

    dkfdkdodkms

    05/07/2023, 1:57 AM
    that global scope, is that a machine or a location?
  • k

    kian

    05/07/2023, 1:57 AM
    It's just a Worker instance
  • k

    kian

    05/07/2023, 1:58 AM
    It's short-lived for a single Worker instance
  • k

    kian

    05/07/2023, 1:58 AM
    Once your Worker stops receiving requests, it's gone
  • d

    dkfdkdodkms

    05/07/2023, 1:59 AM
    got that, but if there was an id i could access that would be the same id the next time it was instantiated, that would be helpful
  • k

    kian

    05/07/2023, 1:59 AM
    You'd probably have to use something in
    req.cf
    like the country or region
  • d

    dkfdkdodkms

    05/07/2023, 2:01 AM
    thank you
  • k

    kian

    05/07/2023, 2:17 AM
    FWIW, https://global-scope.kianorguk.workers.dev will give you an idea of how often you'll hit a new global scope
1...244224432444...2509Latest