Understanding DO Pricing
Hi all, I'm trying to estimate my costs for Durable Objects.
My use case is that I have limited-use, short-lived (less than 5 minutes) tokens that I want to ensure cannot be used more than some amount of times.
It's rare that these tokens are used more than once, so this is mainly to prevent possible abuse.
If I keep create one DO instance for every token, and it takes 1ms to read/store the amount of times the token has been used, and I handle 5,000,000 requests in a month, it's going to cost me $8000 😬
(speaking of which, what's the resolution on the timers used to keep track of usage? milliseconds? microseconds? nanoseconds?)
An alternative I thought of is to use one shared DO instance for everything, but that might cause latency issues (haven't measured yet).
Am I calculating this correct? Or should I try the other approach? Thanks!
3 Replies
That calculation is very far off.
In order to calculate the per millisecond cost from GB-sec you do the following:
$12.50 per million GB-sec
or $0.0000125 per GB-sec
@ 128/1024 GB for ram for a durable object
=
(0.0000125*(128/1024))
= $0.0000015625 per second
or $0.0000000015625 per millisecond
So 5,000,000 requests @ 1ms =
$0.0000000015625 * 5,000,000
= $0.0078125
Less than 1 penny for the duration.
And $0.75 for the requests given $0.15/million for requests🤦
thanks, I forgot to include the million part
okay, much better