Spring / Spring gRPC Interview Questions
How would you implement deadline/timeout handling for gRPC calls from a Spring client?
A deadline is set on the stub before making the call, e.g. stub.withDeadlineAfter(500, TimeUnit.MILLISECONDS).getOrder(request). If the server hasn't responded by then, the call fails on the client with Status.DEADLINE_EXCEEDED rather than hanging indefinitely.
Deadlines are most effective when propagated: if service A calls service B which calls service C, the remaining time budget should flow downstream so C doesn't keep working long after A has already given up. grpc-java can propagate the current deadline automatically to calls made within the same context, which keeps a chain of internal calls from wasting work on a request the original caller has already abandoned.
More Related questions...