Using Upstash

Hey guys,

I was wondering if i could get some insight into the best way to design the following system. I have a rough idea on how to design it but not 100% sure.

So I have IoT devices in the field, and only activate when a certain sensor is enabled (which should send a notification to the user with the data).

Once activated they will start sending data to my api every Xms for Y seconds. (just say data every 500ms, for 10 seconds)

This data is sent over HTTP to my nextjs api with data. Sometimes it might spam the api endpoint if the frequency is quite low. To account for this I dont want to send a user a notification on their phone every time this happens.


Currently what i am doing, is inserting all this data into a
MessageBus
table. which is exactly what it says, a message bus. I've realised this is probably in efficient, and going to move to redis streams on upstash.

Now this is where im a little unsure on what to do next.

So when data comes in from a device, push it to the redis stream. Cool that works, but then how should i know when to send a notification to the user? I would need some form of server that reads the redis stream, and calls the appropriate actions, but this isnt possible to do in nextjs...
Was this page helpful?
Using Upstash - Theo's Typesafe Cult