If possible, how can a timeout be set in the upstream API for the invocation of the first downstream API to meet the new upstream API’s desired SLA?

A new upstream API Is being designed to offer an SLA of 500 ms median and 800 ms maximum (99th percentile) response time. The corresponding API implementation needs to sequentially invoke 3 downstream APIs of very similar complexity. The first of these downstream APIs offers the following SLA for its response time: median: 100 ms, 80th percentile: 500 ms, 95th percentile: 1000 ms.

If possible, how can a timeout be set in the upstream API for the invocation of the first downstream API to meet the new upstream API’s desired SLA?
A . Set a timeout of 100 ms; that leaves 400 ms for the other two downstream APIs to complete
B . Do not set a timeout; the Invocation of this API Is mandatory and so we must wait until it responds
C . Set a timeout of 50 ms; this times out more invocations of that API but gives additional room for retries
D . No timeout is possible to meet the upstream API’s desired SLA; a different SLA must be negotiated with the first downstream API or invoke an alternative API

Answer: D

Explanation:

Before we answer this question, we need to understand what median (50th percentile) and 80th percentile means. If the 50th percentile (median) of a response time is 500ms that means that 50% of my transactions are either as fast or faster than 500ms.

If the 90th percentile of the same transaction is at 1000ms it means that 90% are as fast or faster and only 10% are slower. Now as per upstream SLA, 99th percentile is 800 ms which means 99% of the incoming requests should have response time less than or equal to 800 ms. But as per one of the backend API, their 95th percentile is 1000 ms which means that backend API will take 1000 ms or less than that for 95% of. requests. As there are three API invocation from upstream API, we can not conclude a timeout that can be set to meet the desired SLA as backend SLA’s do not support it. Let see why other answers are not correct.

1) Do not set a timeout –> This can potentially violate SLA’s of upstream API

2) Set a timeout of 100 ms; —> This will not work as backend API has 100 ms as median meaning only 50% requests will be answered in this time and we will get timeout for 50% of the requests. Important thing to note here is, All APIs need to be executed sequentially, so if you get timeout in first API, there is no use of going to second and third API. As a service provider you wouldn’t want to keep 50% of your consumers dissatisfied. So not the best option to go with.

*To quote an example: Let’s assume you have built an API to update customer contact details.

– First API is fetching customer number based on login credentials

– Second API is fetching Info in 1 table and returning unique key

– Third API, using unique key provided in second API as primary key, updating remaining details

* Now consider, if API times out in first API and can’t fetch customer number, in this case, it’s useless to call API 2 and 3 and that is why question mentions specifically that all APIs need to be executed sequentially.

3) Set a timeout of 50 ms –> Again not possible due to the same reason as above Hence correct answer is No timeout is possible to meet the upstream API’s desired SLA; a different SLA must be

negotiated with the first downstream API or invoke an alternative API

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments