Next.js Discord

Discord Forum

Upstash expensive

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Spectacled bearOP
You can setup rate limiting with upstash but one thing I dont understand. They charge 0.20$ per 100k commands but I've noticed that only today by simply developing for my app I've alrwady used 5k commands. I can imagine that this rate limiting is more expensive than spamming my service. If someone would spam 1k requests per second I'd be paying 0.20$ every 100 seconds... Do you guys jave any experience with spammers and how did you deal with them?

Not to mention planetscale mysql is about 10 times cheaper per write. Having the spam limiter with upstash would cost more than letting spam through..

26 Replies

Giant panda
Disable rate limiting while developing locally. Also in case you really get DDoSed then there is a temporary cache preventing calls to Upstash if somebody is spamming too often saving you some money.
In real-case usages it will be comparatively cheap even if at higher loads.
@Spectacled bear heavy traffic situation like DDoS attacked, you could use a global var in front of Redis,
https://github.com/upstash/ratelimit#ephemeral-cache
For extreme load or denial of service attacks, it might be too expensive to call redis for every incoming request, just to find out it should be blocked because they have exceeded the limit.
Spectacled bearOP
Yeah the ephemeral cache would solve extreme spam
I am new to serverless and web services but am i correct if i say the costs are several times higher than self hosting for the benefit of scalability and ease of management
I think i could host a redis instances that can handle several hundred reqs per second for like 3.5€ monthly per region
Giant panda
A bit more expensive, but typically not by insanely huge factors unless you have a bad setup or misconfigure something
i host on GCP, so i use GCP redis.
Giant panda
But Upstash specifically is a bit pricey over something like selfhosting Redis on Railway or Fly due to the convenience and safety
You don't have to bother with maintenance at all
In general using managed services are all like that
Pay people and companies slightly more to deal with something because they know what they do to free you up from dev ops etc.
Spectacled bearOP
I am just imagining people targeting me. Upstash would be more a lot more expensive for me than an attacker would pay
Execept that eph cache solves that nvm
Giant panda
Yeah that's why the cache exists and helps out A LOT
I meant that in my initial message but forgot the terminology
Glad that tafu pointed that out
Spectacled bearOP
I had that already configured. I read the docs 🙂
Golden-winged Warbler
to add to others, it is common to use a local redis container when developing. Managed services can be purchased from many places and is worth shopping around. You'll find options like upstash (focused saas) or a cloud like gcp/aws (not focused, but often more than enough) to self hosted via helm (which has real world experience built in). It is typically very beneficial to host it the same place as your application, or otherwise ensure the latency between your app and the cache is very small, that's the point of the cache after all. For production, many people self host redis because it is a reliable technology, even with a single node, and especially when only used for the cache.
Giant panda
For Upstash Redis rate limiting you don't need a local Redis container
Just disabling during development is fine
Golden-winged Warbler
I'm pointing out that this is not typical, every place I have ever worked uses a hybrid system, because you have a ton of churn in development & ci
much easier and cheaper to spin up a container
@Golden-winged Warbler right. usually Redis cache is used in front of DB to reduce response time so it should sit in the same region(VPN). plus in case of Vercel KV, it does not support Pub/Sub. im curisou abt Dragonfly btw.
Spectacled bearOP
I can literally rent a vps for 3.50/mo and it will be right next to the other hosts
But I guess I will just keep using upstash until I run out of the free tier and then consider whether I can eat the costs of not caring. Hopefully I'll have paying customers