Performance in AJAX on the client side

0

I would like to know which of the two methods that I am going to explain next are more optimal for the Client Side to implement the pagination of search results:

1- Bring todos los elementos that throws the search in a JSON, present only a part and as it changes the page I'm showing different elements from the JSON that I already have.

or

2- Bring only los primeros N elementos in a JSON and as the page changes request the server via AJAX the corresponding elements.

    
asked by Genarito 15.12.2016 в 15:34
source

2 answers

0

Each option has its pros and its contras .

OPTION 1: Return all records

PROS:

  • Server load : It is not necessary to reopen a connection to the server each time a filter is applied.

  • Performance on the client : When applying a filter / search the waiting time will surely be less.

CONS:

  • Traffic : The data volume ( bytes ) transferred to the customer is significantly higher. This can bring extra costs if you have a low percentage of the data output limit, as well as on mobile phones with limited data packages.

  • Load in client memory : Storing a lot of information in the client means that it requires more quota .

//

OPTION 2: Return RAM records ( N )

Basically the opposite.

PROS:

  • Traffic : The data volume ( paginar ) transferred to the customer is significantly lower.

  • Load in customer memory : Storing little information in the client means that it requires less bytes .

CONS:

  • Uploading the server : It is necessary to reopen a connection to the server each time a filter is applied.

  • Performance on the client : When applying a filter / search the waiting time will surely be longer.

//

Personally I think that the best option depends on the scenario that is presented. I always lean towards RAM , since usually, initially one always returns ( or so I think ) what the user wants to see and the rest is " paginar "

    
answered by 15.12.2016 / 16:10
source
0

You could benchmark it but it will always depend on the number of records you have. If you do not know how much that database can grow the most efficient both in terms of server and client would only recover N results by request.

    
answered by 15.12.2016 в 15:52