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

    p0

    01/01/2023, 4:18 AM
    It's an API that fetches from another server and parses everything nicely and cleans everything up a lot. It's surprising what people pay for this kind of stuff.
  • s

    sks

    01/01/2023, 4:18 AM
    But DO also has a running cost associated with it.
  • u

    Unsmart | Tech debt

    01/01/2023, 4:18 AM
    And DOs have memory so you don't even need to do a read every time
  • u

    Unsmart | Tech debt

    01/01/2023, 4:18 AM
    Very very low since storage is fast
  • d

    Deleted User

    01/01/2023, 4:18 AM
    o thats cool i didnt know u could avoid reads
  • u

    Unsmart | Tech debt

    01/01/2023, 4:19 AM
    I pretty much omit the costs of duration in DOs if I'm only doing storage ops
  • p

    p0

    01/01/2023, 4:19 AM
    durable objects seems like the right solution.
  • s

    sks

    01/01/2023, 4:19 AM
    DO is also billed in GB-s. But it is still something if the API is being spammed. But I guess I have to test both cases and do the math.
  • p

    p0

    01/01/2023, 4:20 AM
    from what you're saying, it doesn't seem like it'd cost too much
  • p

    p0

    01/01/2023, 4:20 AM
    @Unsmart | Tech debt this is a really tough question to answer on the spot, but per request, how much do you think it'd cost (excluding regular worker request cost)?
  • d

    Deleted User

    01/01/2023, 4:21 AM
    per request is hard to calculate because u don’t set an alarm on every request to delete the count after a day
  • p

    p0

    01/01/2023, 4:22 AM
    wdym?
  • s

    sks

    01/01/2023, 4:22 AM
    Another approach which I was going with would be to use a single DO for like 100 customers. Beacuse there would a Cloudflare Rate Limiting rule anyway. So a customer can make like 1 request per second. And so I can use Hashing to dynamically allocate 1 durable object per 100 customers. (DOs have a an approx performance of 100 req/s. I got it from the docs)
  • d

    Deleted User

    01/01/2023, 4:23 AM
    your use case would be limiting requests per person for a day, so after a day you would clear the count and start fresh. That way you don’t have linear storage growth
  • s

    sks

    01/01/2023, 4:23 AM
    By the way Happy New Year 🥳 to all of you guys.
  • p

    p0

    01/01/2023, 4:24 AM
    oh yeah forget about that
  • p

    p0

    01/01/2023, 4:24 AM
    happy new year
  • u

    Unsmart | Tech debt

    01/01/2023, 4:24 AM
    Like maybe $1.40/million since you'd read + write (invoke is 0.15/million read is 0.20/million writes is 1.00/million and add 0.05/million for duration just in case 🤷) But if you save the request count in memory on the DO it could also be lower and if people hit their limits the costs will also be lower since you don't need to do the write. Ultimately the best way to know for sure is to actually write the code and see what it costs in practice
  • p

    p0

    01/01/2023, 4:25 AM
    ah
  • u

    Unsmart | Tech debt

    01/01/2023, 4:25 AM
    That of course doesn't include the actual storage cost but I assume that's probably minimal for strictly rate limiting
  • p

    p0

    01/01/2023, 4:25 AM
    damn that's pricey compared to a regular workers request.
  • p

    p0

    01/01/2023, 4:25 AM
    but it's worth it for me
  • p

    p0

    01/01/2023, 4:25 AM
    because I want to reap the benefits of edge computing
  • s

    sks

    01/01/2023, 4:26 AM
    But you do have to setup a cloudflare rate limit rule to prevent abuse.
  • p

    p0

    01/01/2023, 4:26 AM
    hopefully in the future they make a better way of doing this simple task that I feel like is kind of overpriced currently
  • p

    p0

    01/01/2023, 4:26 AM
    really?
  • u

    Unsmart | Tech debt

    01/01/2023, 4:27 AM
    Just make sure you create a DO per customer or you could run into issues with request rate. A single DO instance can do about 500 rps max from my testing of a simple rate limiter
  • p

    p0

    01/01/2023, 4:27 AM
    if I already have a cap, do I need to prevent abuse through a rate limit?
  • p

    p0

    01/01/2023, 4:27 AM
    gotcha
  • u

    Unsmart | Tech debt

    01/01/2023, 4:29 AM
    Cloudflare does technically have a 100% free rate limiter it just doesn't let you set a custom limit for each user independently you set the same limit for all
1...469470471...567Latest