Default deadline per call

476 views
Skip to first unread message

Ryan Michela

unread,
May 31, 2017, 3:49:21 AM5/31/17
to grpc.io
As indicated in this thread, a fresh deadline should be created for every call. What is the best way to override the default deadline for a Client so that every request uses a fresh deadline with the same duration?

Should I create a ClientInterceptor to fiddle with CallOptions.withDeadlineAfter() for every request?

Carl Mastrangelo

unread,
May 31, 2017, 1:09:22 PM5/31/17
to grpc.io
Personally I would use an interceptor if there aren't many different many different kinds of methods.  

Another option is to put the deadline in the proto file (assuming you are using protobuf), as a method option.  This would need special handling to make sure you still inherit the deadline from the context, but you could read that from the interceptor easily.

Ryan Michela

unread,
May 31, 2017, 1:34:40 PM5/31/17
to Carl Mastrangelo, grpc.io
I really like the idea of using a proto option to communicate intended deadlines for each operation. As an API publisher, that is a great way to communicate to my consumers an SLA around operation response times.

I'm imagining the interceptor could apply a deadline according to a hierarchy:
1. If the request already has a deadline set, use that, otherwise
2. If the method has a deadline proto option, use that, otherwise
3. If the service has a deadline proto option, use that, otherwise
4. If a global maximum deadline has been set, use that

Explicit request deadlines and global maximum deadlines are set by the consumer, so if they are tighter than the proto's SLA, they should override. There should also be a flag to indicate that a global deadline can explicitly relax an SLA.

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/vykkmkIdMEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/66faf6e5-2fbe-4745-a9bc-9f77bb1c3027%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Carl Mastrangelo

unread,
May 31, 2017, 1:58:07 PM5/31/17
to Ryan Michela, grpc.io
Be warned, the deadline can become out of date, and it will be hard to change.  A 5 second deadline may have been appropriate at one point, but it could change.  You would have a hard time fixing it.  One thing you might be interested in is Service Config ( https://github.com/grpc/grpc/blob/master/doc/service_config.md )  which allow you to describe the timeouts for your methods.  This happens automatically, and comes as part of the DNS name resolution (it arrives as a TXT dns record).  I don't know how widely implemented it is today, but it will eventually be.  

Craig Tiller

unread,
May 31, 2017, 2:19:24 PM5/31/17
to Carl Mastrangelo, Ryan Michela, grpc.io
Prefer service configs here. Recommended deadlines will change - and if there's ever a second implementation of the interface you're exporting, it will likely have different recommended deadlines also.

On Wed, May 31, 2017 at 10:58 AM 'Carl Mastrangelo' via grpc.io <grp...@googlegroups.com> wrote:
Be warned, the deadline can become out of date, and it will be hard to change.  A 5 second deadline may have been appropriate at one point, but it could change.  You would have a hard time fixing it.  One thing you might be interested in is Service Config ( https://github.com/grpc/grpc/blob/master/doc/service_config.md )  which allow you to describe the timeouts for your methods.  This happens automatically, and comes as part of the DNS name resolution (it arrives as a TXT dns record).  I don't know how widely implemented it is today, but it will eventually be.  
On Wed, May 31, 2017 at 10:34 AM, Ryan Michela <delt...@gmail.com> wrote:
I really like the idea of using a proto option to communicate intended deadlines for each operation. As an API publisher, that is a great way to communicate to my consumers an SLA around operation response times.

I'm imagining the interceptor could apply a deadline according to a hierarchy:
1. If the request already has a deadline set, use that, otherwise
2. If the method has a deadline proto option, use that, otherwise
3. If the service has a deadline proto option, use that, otherwise
4. If a global maximum deadline has been set, use that

Explicit request deadlines and global maximum deadlines are set by the consumer, so if they are tighter than the proto's SLA, they should override. There should also be a flag to indicate that a global deadline can explicitly relax an SLA.
On Wed, May 31, 2017 at 10:09 AM, 'Carl Mastrangelo' via grpc.io <grp...@googlegroups.com> wrote:
Personally I would use an interceptor if there aren't many different many different kinds of methods.  

Another option is to put the deadline in the proto file (assuming you are using protobuf), as a method option.  This would need special handling to make sure you still inherit the deadline from the context, but you could read that from the interceptor easily.

On Wednesday, May 31, 2017 at 12:49:21 AM UTC-7, Ryan Michela wrote:
As indicated in this thread, a fresh deadline should be created for every call. What is the best way to override the default deadline for a Client so that every request uses a fresh deadline with the same duration?

Should I create a ClientInterceptor to fiddle with CallOptions.withDeadlineAfter() for every request?

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/vykkmkIdMEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.


--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages