Reputation: 483
I have two services: Service I retrieve last year of user's history. The service II retrieve benchmarks of user's history, but sometimes i need call service II 4 times (with different parameters). So, i do 5 requests.
But, i can create some service to do a left join in all benchmaks with user's history. But in this case, backends will be worst performance.
So, what's the best? - Keep 5 requests and create some logic to merge this data in frontend, or - make one request: increase backend's complexity but keep frontend simpler
PS: My services run in AWS lambda.
Upvotes: 0
Views: 84
Reputation: 16047
Try both approaches. Benchmark. Compare.
The answer depends on many thing depending on which part is the bottleneck.
Actual experience:
I have a project where I have one request that retrieves everything I need using many joins. It worked great at first and it was better than having many separate requests. The frontend-backend HTTP request was the bottleneck.
Eventually, as the database grew larger and the database query involved too many rows, the backend became the bottleneck. At this point, it was better to do several requests and do the joins in the frontend in order to lessen the load on the backend.
Upvotes: 1