Using server function or doing work on client

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)

This is a good question and the answer will really depend on the overall app design, dataset size, what type of tasks they are and about 10 other variables.

In one aspect, the more you do on the client, the lesser the cost. It also may be ‘faster’ since the resulting data is local and more convenient as results can also be processed while offline.

On the other hand, servers are really good at processing massive datasets - for example suppose there are 100 million objects and you want some subset or some single result. Well, storing that much data on the device is probably a bad idea; storing it on the server however is ‘easy’ and processing through all of that on the server offloads that task from the device.

So - great question but probably unaswerable without really digging deeply into the use case.