0

We have a single page app built in Angular 5 using some PrimeNg components in Front-end and Web APIs to fetch the data from back-end. We are trying to improve the performance of the application and we noticed that one of the pages makes like 30 different API calls (of course, it has 8 to 9 different PrimeNg components to display on the page). So, the question is would performance improve if we structured calls differently (i.e. fewer calls by combining some)? Looking for any best practices for single page apps on how many API calls is too many? Would like to also look at some of the popular single page apps to see if they make too many small API calls Vs. few large calls?

sankar
  • 807
  • 8
  • 11
  • 2
    `would performance improve if we structured calls differently` <= It depends. This question is too broad. If you want to know where you can achieve performance gains I suggest you **profile the application stack** at run time to see where the most time is being lost and what incurs the most cost (memory/cpu/IO) and focus on those areas. Other than that don't make your application excessively "chatty", that is lots of small calls but lots can be relative and possibly even insignificant to what else is going on in the app. – Igor Sep 11 '18 at 18:43
  • 30 requests at one time is too much. Read [this](https://stackoverflow.com/questions/561046/how-many-concurrent-ajax-xmlhttprequest-requests-are-allowed-in-popular-browse). I solved such problem using `Batch Requests` – Oleg Dikusar Sep 11 '18 at 19:20

2 Answers2

0

If you reduce the number of requests the performance will increase, because the browser limits the number of concurrent requests to a same host, so it will require that some responses come before making new requests.

justcode
  • 1,562
  • 3
  • 14
  • 25
0

Browser has limitation on max concurrent request, so more request than threshold would be queued which going to increase the response time.

how many API calls is too many?

Firefox 2:  2
Firefox 3+: 6
Opera 9.26: 4
Opera 12:   6
Safari 3:   4
Safari 5:   6
IE 7:       2
IE 8:       6
IE 10:      8
Chrome:     6  

So first step to improve the performance would be to reduce the number of simultaneous request to server .

Dipak Telangre
  • 1,792
  • 4
  • 19
  • 46
  • Current Safari version is 11. This information is very outdated. – Oleg Dikusar Sep 11 '18 at 19:29
  • It is worth mentioning that this limitation is rooted in the protocol (TCP/IP layer). Every request introduces overhead that in turn causing congestion. – refaelio Nov 14 '19 at 07:54