In multiple places of our app there are complex tasks, such as big aggregation pipelines gathering data with $lookup (using GraphQL), processing this data e.g. by calculating something and writing to the database again and more. At the moment most of this work is done on the client, sometimes sending multiple network requests to the server (read with aggregation pipeline, …, write to the server, …)
I realised this could also be implemented using the server functions that are called by the client, and receiving on the client only the final result through a callback for example.
Now I am wondering what method is advised? I imagine there is a difference in performance, price, …? (due to calculation times, amount of requests, …)
I also read that it is advised to let the client do as much work as possible, since it is “free” in terms of server load. Our app will have potentially 1000s of users, making these requests and calculations simultaneously…
P.S. In one case the client writes something to the DB, then we have a trigger performing some function. By instead directly calling a function from the client, writing within that function to the DB, we would have the benefit of receiving a callback once the function has finished running, which is not the case when using a trigger…
P.P.S. We are developing natively for iOS (Swift)