Jitendra Vyas
Jitendra Vyas

Reputation: 152617

Client-side processing vs server-side processing , which is fast?

Which processing is fast Client-side or Server-side? for client side processing browser need to download every JavaScript first and in server side programming everything happens on server without downloading anything to user PC?

if for a particular functionality we have solution in both javascript and php/asp then what should be chosen and why?

Upvotes: 3

Views: 3714

Answers (3)

Mic
Mic

Reputation: 25154

I'm a big fan to move all possible processes on the browser.If you target JS enabled browsers(ie: for a web app)

Mainly to offload the server of the rendering process and save some network bandwith.

Rendering HTML client side is really fast today, even on web enabled mobile phones, why not use this computer power available in the browser?

And once the HTML's, CSS and JS are in the browser cache (in the current session or a previous one) only the data is traveling the network.
And if you put all those static files on a CDN, imagine the gain in speed.

These options in my experience gives a much more responsive experience to the user.

We are kind of mad about speed and it was the design we took to build our web app:

  • static files on a CDN
  • a backend to serve only JSON services and handle security
  • and we use PURE to render the JSON in HTML client side

Upvotes: 1

Itay Maman
Itay Maman

Reputation: 30723

There are several factors, and several trade-offs, to consider here.

The server machine is usually stronger than the client machine. OTOH, there are usually far more clients than servers. Thus, when #clients exceeds a certain threshold, client-side processing is faster (the server will have to process computations from all clients which will outweigh its stronger processor).

But, if the processing is bounded mainly by network bandwidth, that is: most processing time is spent on downloading stuff, and the downloaded material is relatively stable, then it will be faster to download once into the server and do the processing there.

Finally, if the results of the computations do not change from one client to another, then - again - it makes more sense to compute it, once-and-for-all, at the server.

Upvotes: 1

Quentin
Quentin

Reputation: 943142

Downloading the JavaScript upfront is usually quicker as a server round trip isn't required (and it is networking operations that are usually the most time consuming).

That said, there should always be a server side solution for any essential functionality (as JS support is not guaranteed), and performance shouldn't be the first thing you think about (trust should be, e.g. you can't trust client side code to make certain that data isn't going to trash your database).

Upvotes: 2

Related Questions