We are developing a REST API which among others is going to be consumed by an HTML5 frontend via javascript. The application is for use within the organization and usually has about 300 users, but we want to scale well up to 1000 users or so.
Normally connections to the API will be made within the LAN so the quality and latency of the connection will be good, although it is not excluded occasional use over the Internet where connections could be slower and with more lag via 3G/4G.
The two options that we thought are:
The frontend will make several simultaneous asynchronous calls to the API to load the various components of the interface.
- Pros: Simplicity.
- Cons: More connections to the server.
The controller of the frontend will make a single call to the API passing as parameters which objects need to be fetched.
- Pros: Only one connection to the server, although the server will make several connection to the database.
- Cons: Requires mechanisms in both frontend and API. It complicates the design.
Further explanations: There will be different resources .../Product .../Locations etc. These resources could be fetched alone, but there will be another abstract resource .../screen?Product&Locations that will fetch both in one call.