Java – where to run complex algorithms? Server or client?
I'm trying to develop a social network Android application with a huge user database I am very new to android app development and try to understand the concepts behind application development
1) MySQL PHP (restful Web Service) 2) Android studio (Java)
In the application, I must run some complex algorithms to rank the data collected from different tables in the database stored in the ECS
My question is "where to run this algorithm?" I should write code in PHP to make the algorithm run on the server, and then send the data to the client (or) I should write code in Java (Android studio) using the data collected from the server
How does the performance of my application differ in these two cases?
Editor: Thank you for all your responses
I have the idea of asynchronous tasks and multithreading
This question comes to me because ranking is common and different for all my users If I put the rake algorithm on the server, even if the results of all users are the same, the same algorithm must run multiple times (if there are 10000 users, the same algorithm runs 10000 times on the server) But if I put it on the client, I might come over But expert solutions are needed
Solution
Some of this may be opinion based, but I think there are several design rules that can be used as guiding principles:
>When a large amount of data is required for calculation, close to the data as much as possible This is usually in the database itself Transferring large amounts of data is a good idea for resource intensive rather than slow links, such as between servers and clients. > If the calculation needs to process private data, you can also set the distance that the data can be used for calculation purposes Do not display client data, not protect private data! > When computing is resource intensive, it is effective for many users. It can even calculate in advance, execute on the server and cache the results. > If the computation requires little data but is computationally intensive, can you expand enough servers to maintain concurrent requests from all clients Client computing can lead to more stable performance, although the client's resources are limited (still available!)