Splitting big request in multiple small ajax requests

Posted by Ionut on Programmers See other posts from Programmers or by Ionut
Published on 2012-11-12T09:20:39Z Indexed on 2012/11/12 11:20 UTC
Read the original article Hit count: 286

Filed under:
|

I am unsure regarding the scalability of the following model. I have no experience at all with large systems, big number of requests and so on but I'm trying to build some features considering scalability first.

In my scenario there is a user page which contains data for:

  1. User's details (name, location, workplace ...)
  2. User's activity (blog posts, comments...)
  3. User statistics (rating, number of friends...)

In order to show all this on the same page, for a request there will be at least 3 different database queries on the back-end. In some cases, I imagine that those queries will be running quite a wile, therefore the user experience may suffer while waiting between requests.

This is why I decided to run only step 1 (User's details) as a normal request. After the response is received, two ajax requests are sent for steps 2 and 3. When those responses are received, I only place the data in the destined wrappers.

For me at least this makes more sense. However there are 3 requests instead of one for every user page view. Will this affect the system on the long term? I'm assuming that this kind of approach requires more resources but is this trade of UX for resources a good dial or should I stick to one plain big request?

© Programmers or respective owner

Related posts about scalability

Related posts about best-pactice