We are working with a performance metric that all API requests should respond within 50ms when running locally. I am taking this from the average response time of Githubs API.
I have an object called Foo. A single Foo might contain 6KB of text when serialized as json.
Foo has a sub object which makes up about 3KB called Bar.
There is an endpoint in my API which returns a page of Foos at a time eg:
https://apidomain/v1/foos?pageSize=25
The response for a single page of 25 Foos is then ~150KB. This takes 75ms to respond when running locally.
There is a design option to take the Bars out of the Foos object, and make them available as a sub object like this:
https://apidomain/v1/foos/fooId123/bar
This would bring the response for a single page of 25 foos is then down to 75KB. With an extra request needed to get the bar for that foo. This brings the avg response time closer to the goal of 50ms.
When designing a RESTful API and it's object definitions, what is the ideal response size if 50ms is an ideal response time?
What other considerations should I have when designing API objects and sub objects?