Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to run complex algorithms? Server side or Client side? [closed]

I am trying to develop an social networking android application which contains huge database of users. I am very new to Android App development and trying to understand the concepts behind the app development. I am using following technology :

1) MYSQL + PHP (RESTful Web Services) 2) Android Studio (Java)

In the application, I have to run some complex algorithms for ranking users collecting data from different tables from database stored in cloud server.

My question is "where to run this algorithms?". Should I write code in PHP to make the algorithms run in server side and then send this data to client (or) Should I write the code in JAVA (Android Studio) using data collected from server.

How will the performance of my app differs in both cases?

Edit : Thanks for all your responses.

I have idea on Async Tasks and Multi Threading.

This doubt came to me as ranking is common for all my users, there is a difference. If I put raking algorithm in server side, even though the results are same for all users, the same algorithm has to run for several times (say if there are 10000 users, the same algorithm runs for 10000 times on server side). But if I do put in client side, I may over come this. But need expert solution on this.

like image 825
Chaitanya Chikkala Avatar asked Jan 03 '17 09:01

Chaitanya Chikkala


People also ask

Which is better client-side or server-side?

Between the two options, server-side rendering is better for SEO than client-side rendering. This is because server-side rendering can speed up page load times, which not only improves the user experience, but can help your site rank better in Google search results.

Is client-side faster than server-side?

Server-side scripting is generally faster than client-side scripting.

Which model is a client-side model?

The client-side model is the basis for much of the internet. In the model, user devices communicate via a network with centrally located servers to obtain the data they need, rather than communicating with each other.

What is client-side and server-side programming?

In client-side development, the code runs on the client's or user's device. In server-side development, the code runs through a server.


1 Answers

This question may be somewhat opinion-based, but I think there are a few design rules which you can use as guidelines:

  • When a computation needs lots of data, do it as close to the data as possible. This is often on the database itself. Transferring large amounts of data is resource-intensive and not a good idea over a slow link (e.g. between the server and the client).
  • If the computation needs to deal with private data, the bounds how far the data can travel for computation purposes is also set. Not displaying the data in the client is not protection of private data!
  • When a computation is resource-intensive can be cached, is valid for many users, and maybe even computable in advance, do it on the server and cache the result.
  • If the computation needs little data but is computation-intensive, ask yourself if the server can scale well enough to sustain all clients making concurrent requests. Having the client compute such operations can lead to a much more stable performance overall, despite the limited resources of the client (which nowadays is still pretty usable!).
like image 151
Lucero Avatar answered Sep 22 '22 00:09

Lucero