I've been using NextJs on Vercel for a while now because of its amazing development experience and performance but I didn't need to use real-time data with WebSockets in any of my applications until now.
At the moment, however, I'm working on a new project that needs real-time but I'm struggling to decide how to implement WebSockets.
To give a little bit of context, this application is a real-time trading market where users exchange virtual assets for money. Therefore, there's a need for WebSockets to keep clients updated on new listings on the market, as well as a background job running every few seconds to track if trades were completed, canceled, etc.
Keeping in mind that I would like to keep using NextJs hosted on Vercel, my question is: should I create a separate server to handle all real-time data and background jobs while using NextJs or should I go with the normal React + ExpressJs + WebSockets server? I've also thought about using AWS services but I think it would be tricker than the other two alternatives.
And If I were to create a separate server, would it be ideal to use Serverless Functions (created on Vercel) to do database operations and then notify the WebSocket server to replicate the changes (e.g. create a new item listing)? Or should I use the WebSocket server's routing (ExpressJs routes) to perform those types of tasks that need to be replicated to the client?