node.js – How to reduce http call to server? – Stack Overflow
I know this is a pure system design question but I am still asking because of unique architecture of my application. My app has 40 million userbase. Backend is made in node js, microservices based architecture and using red hat datagrid.
I have like 40 api calls made in my backend where data is coming from unique tables in mongodb. These api calls are being called by front end ( android, ios ) users multiple times due to which no of calls are going in millions. Lets leave rate limiting for now. My problem is to reduce the no of api calls to backend server. Even though we are using datagrid and cache all the apis content. But for optimization we need to reduce the number of api call to server and improve the latency.
I want to configure the cache time ( how long the api response should be cache ) at front end from backend.
Below is the solution which i have made with my understanding.
1. what if we club all the static apis at backend give them one route name lets say
api/v2/x/static and cache them
2. Front end will replace all the static apis like ( x, y z ) with above api call.
3. We will use firestore trigger logic and maintain a variable there for emergency or
normal changes when ever we change some thing we can always change the firestore variable value.
By doing above solution we can reduce number of api call, cache meachanism will be at both backend and front end, future changes can easily reflect any time. We can always do some tweaks from backend side.
But the question is if we club these apis their response payload will be greater in numbers it will be like 200kb.
Whats your solution ?
Read more here: Source link