WebSocket workflow for serverless with T3 stack
I'm just starting with WebSockets, and would like to get confirmation if I'm on the right track regarding how the communication between services is made. The basic pitch for the part of the project I want to discuss is the following: 2 users send information to the server. The information is only processed when both of them deliver their data, and then is sent back via a WebSocket subscription for both of them. Also, in order to process this new information to send to them, I need not only the data sent from both the users, but the previous processed information as well (this, I believe, means I'll need to store this processed information somewhere that is quickly retrievable so I can get it back in the next round of requests).
The workflow I had in mind is like this:
- User 1 makes a POST request for Next.js with the desired data
- Next.js gets Redis' data to confirm if User 1 is the last to post in this round
- Since it's not, Redis' data is updated to include User 1's data in this Round
- This triggers the Pusher subscription to send to the Client the list of users who sent and who still did not send the data
- User 2 makes a POST request for Next.js with the desired data
- Next.js gets Redis' data to confirm if User 2 is the last to post in this round
- Since it is, we get Redis' data of the previous processed information
- A function is executed to create a new processed information (it takes both users's data and the previous processed information, all which we got from Redis and the User 2 POST request)
- This new processed information is stored in Redis alongside the User 2's data, so we have both their data and the processed information that was a result of it
- Both the Processed information and the list of users who sent and who still did not send the data are sent to the Client via Pusher's subscription
- Client reads and shows this processed information and a new round is initiated
Is this the right workflow with serverless? Is it wrong? Overkill?
The workflow I had in mind is like this:
- User 1 makes a POST request for Next.js with the desired data
- Next.js gets Redis' data to confirm if User 1 is the last to post in this round
- Since it's not, Redis' data is updated to include User 1's data in this Round
- This triggers the Pusher subscription to send to the Client the list of users who sent and who still did not send the data
- User 2 makes a POST request for Next.js with the desired data
- Next.js gets Redis' data to confirm if User 2 is the last to post in this round
- Since it is, we get Redis' data of the previous processed information
- A function is executed to create a new processed information (it takes both users's data and the previous processed information, all which we got from Redis and the User 2 POST request)
- This new processed information is stored in Redis alongside the User 2's data, so we have both their data and the processed information that was a result of it
- Both the Processed information and the list of users who sent and who still did not send the data are sent to the Client via Pusher's subscription
- Client reads and shows this processed information and a new round is initiated
Is this the right workflow with serverless? Is it wrong? Overkill?

