Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processing data server-side vs client-side

I'm using PHP to pull financial data from yahoo. Then I'm sending the data in JSON format to one of my Typepad blogs and receiving it with JavaScript.

Is it faster to process the data on the server-side, then send the JSON subset to JavaScript. Or would it be better to send the whole thing, then process it with JavaScript on the client side?

How do I learn how to make this type of trade-off analysis on my own?

like image 960
Dave Stibrany Avatar asked Feb 17 '11 15:02

Dave Stibrany


People also ask

What is the difference between client-side and server-side processing?

Client-side means that the processing takes place on the user's computer. It requires browsers to run the scripts on the client machine without involving any processing on the server. Server-side means that the processing takes place on a web server.

Should data processing be done on client or server?

In general, if you have lots and lots of data, maybe several thousands or millions of rows, it is better to perform processing on the server instead of the client. For example if paging and sorting are processed on the server, we only need to send a few rows (10, 15, 20 or may be 100).

Which is better server-side or client-side rendering?

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.

What is server-side processing?

Server-side processing happens when a page is first requested and when pages are posted back to the server. Examples of server-side processing are user validation, saving and retrieving data, and navigating to other pages.


1 Answers

Mostly good estimating. Sending large amounts of data to the client for processing will incur client overhead and make their browsing experience less acceptable. Processing data server side will increase your server load per client.

This is a common situation seen with large tables of data that are sortable or paginated. You can either do that entirely in browser or enable server side sorting and paignation. My rule of thumb is if I have more then 10k cells (10 columns x 1000 rows) then I should probably enable server side processing instead of leaving it up to the client. This is especially true on older machines with shitty slow JavaScript engines.

like image 162
Josh K Avatar answered Sep 28 '22 11:09

Josh K