I am developing an Android app with sails.js backend. Assume that I have 3 different APIs, namely A, B and C. These APIs only fetch data return them with minor / no computations or update values in the databases. Each of these APIs take 300-400ms respectively on live.
Currently, I am running on a micro EC2 instance of Amazon Linux, which will be scaled as more users come in.
Is it a good idea calling 3 APIs from the Android app or having a single APIs which performs the job of all 3 APIs in a single call? My idea of creating 3 different APIs is to reuse the same in my AngularJs front end.
But in most cases our servers will reject API requests from a particular application if the request rate exceeds 30 API requests per minute. In this case the client will get an HTTP error with status code 429 “too many requests”.
To answer your question, yes it is normal to have several microservices (small APIs) working together in a solution.
For fetching the performance reports of monitor groups, it is recommended to call the API on a hourly basis, as the data archiving is done only once in 60 minutes.
It is a good idea in terms of reusability as you're already using these APIs. But I would still go with an API that summs up the functionality of three calls with one just because mobile device don't always got a good internet connection. Using a single API call requires less traffic and decreases the loading and response time. I would recommend measuring the API call time with the android emulator using extreme connection settings (EDGE, high latency) and compare the results.
Try to use thread for each api, In android we use handler in the form of thread .You can run the api,s one by one by using handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With