I'm developing a small public website for fun that makes calls to a route, which makes a few other calls to the OpenAI API, and I want to rate limit that route. I may be over-engineering a bit, but there's really nothing stopping an (anonymous) user from pasting a setInterval in their browser and spamming the API.
I've been researching for a while now and found that a lot of people have recommended Vercel KV, which I couldn't find anything updated (maybe it's deprecated?), and Upstash Redis. I tried the latter, and it was pretty easy and good, but then I realized that I had already made almost 1k out of 10k requests in the development environment in just a few hours (I use it for both caching and rate limiting), which means that eventually the API spam would affect the service anyway. Digging through the source code of the libraries, I found that there is an option to set the local cache behavior[1][2], but I'm not sure how effective it is.
For those who used the free tier, was it enough? Does Vercel have anything for free that could help, since this also affects their infrastructure?
I am a beginner in database usage and I've decided to explore my option, and landed on redis with serverless option by Upstash. I've been following along this great video by Josh tried coding
However, as I implement my code, the commands usage in the Upstash dashboard keeps on incrementing by the seconds without me making any call to the Upstash redis. It looks something like this
with SCAN, EVAL being the most used even though the operation that I'm using are `rpush`, `sadd`, `hset`. But after a while those commands usage in the dashboard resets back to 0.
Is this something i should worry about, or is it just a normal behaviour?
Cheers
Videos
I'm using fluid compute Node.js (not edge). Is Upstash Redis or Redis better? I notice under Redis it says "Serverless Redis", but how is it serverless? I thought Upstash Redis was HTTP-based (good for serverless) and Redis was TCP based (bad for tons of connections).
Lets say I had this code and I'm using Upstash.
async function getMovieById(id) {
let movie = await redis.get(`movies/${id}`);
if (movie) {
return movie;
}
movie = await db.findMovieById(id);
invariant(movie != null, "movie not found");
await redis.set(`movies/${id}`, movie);
return movie;
}If I reach my free limit on space/request/etc on upstash redis, will this throw an exception and my endpoint will be f*ck?
I want to be sure If I need to abstract all to avoid those exceptions
I'm trying to use Upstash Redis as the main database for my application, with the @upstash/redis REST client since it's a serverless application. Currently I'm modeling my data like this:
const accountId = '123';
const accountData = {
email: '[email protected]',
slug: 'abc',
...other account data,
}
await redis.set(`account:${accountId}`, JSON.stringify(accountData));
await redis.set(`email:${accountData.email}`, accountId);
await redis.set(`slug:${accountData.slug}`, accountId);This lets me store all my account data in a single record, and then be able to fetch that by email or slug. My worry is the first action will create the account record, and then something will happen to cause the second and/or third action to fail leaving the account data siloed and inaccessible.
The issue with this (other than the unused storage growth implications) is that my application is privacy focused and I want users to have the ability to know/delete all the data I store about them, and I can't do that if theres siloed copies stored all over the place I can't find.
In REST API docs in says that transactions aren't supported so I cant use that. Is there any other way to mitigate this issue or is just something I'll have to live with and hope it doesn't happen often?
» npm install @upstash/redis
I've made a chat-application project using spring boot, where i'm sending chat messages to kafka topics as well as local redis. It will check first if messages are present in redis, if yes it will populate the ui otherwise it will fetch data from kafka. If I host this application on cloud, how will i make sure that local redis server is up and running on the client side. For this, if i use a hosted redis server for eg. upstash redis which will be common for all redis clients, how will it serve the purpose of speed and redundancy, because in any case the client has to fetch data from hosted redis or hosted kafka.
I used redis for faster operations, but in this case how will a hosted redis ensure of a faster operation.
Can you use modules such as RedisJSON and RediSearch on Upstash?
I've only used the ioredis client for light use of simple data structures.
While I have been brushing up on RedisJSON, I cannot find any documentation for it's use on Upstash. Also reJson commands didn't seem to be recognized by the Upstash dashboard CLI.
If they do not have support, any leads on where I should turn? RedisLabs perhaps?
» pip install upstash-redis
Reference: https://vercel.com/templates/next.js/api-rate-limit-upstash
If I understand correctly, even after the user hits their limit and starts getting 429 back (which would then not hit the serverless endpoint for the next edge function)-- they could still continue to spam which would then still accrue lots of costs on the Redis Upstash KV side, right? Or am I misunderstanding something?
If I'm not misunderstanding, is there a way to have a spend cap on Upstash KV?
I'm building a little website for my wife's shop currently, and my frontend part is using NextJS and is deployed on Vercel. Just recently I realized that I need some backend, a small database practically, for keeping the order forms from potential clients. Additionally, the db might come in handy in the future, if we decide to develop the store.
So, Vercel has its Redis instance (Vercel KV), but it's struggling with finding the keys in the env files for some reason (error example: '@vercel/kv: Missing required environment variables KV_REST_API_URL and KV_REST_API_TOKEN'). Also, Upstash has a Redis instance, which looks like Vercel KV. And we have pure Redis with its downloadable GUI.
Which one to choose or there's no big difference, just some features, prices and interfaces? I've been triyng Vercel KV for a couple of days, but it won't work.
Hello everyone!
I haven't been able to find a solution and I hope you can help me. I have a JS project that works with an Upstash Redis KV config. This one works great with my Vercel Free account.
However, I created a fork of my repo into my client’s GitHub that has a Vercel Pro account and when I create the same Upstash configuration that I’m using in my personal account, it doesn’t work. I already tried the “ioredis” library and also the REST endpoint, nothing worked.
Any suggestions? Is this related to the Vercel Pro account or something else?
Thank you!🙏🏻