question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How does deadline work?

See original GitHub issue

I’m creating a blocking stub with deadline:

blockingStub = MyGrpc
        .newBlockingStub(channel)
        .withDeadlineAfter(3, TimeUnit.SECONDS);

and then I start calling method in a loop:

for (int i=0; i<100; i++) blockingStub.doSomething();

first 8 calls are handled correctly but others end with DEADLINE_EXCEEDED exception. Looking at my gRPC server logs I can see that the 8th call (last succeeded call) is ~3 seconds after the 1st one, so I assume that the deadline I set is for all my calls. How to set up a deadline per call ?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, Feb 29, 2016

A deadline is a fixed point in time, like 8:10 AM on Feb 29th. A timeout is a relative time, like 3 seconds. gRPC is using deadlines, not timeouts, as they work much better when you many things you need to do by a certain time.

To have each RPC last up to 3 seconds, you could do:

for (int i=0; i<100; i++)
    blockingStub.withDeadlineAfter(3, TimeUnit.SECONDS).doSomething();

There are some plans to support timeouts, but they are part of larger per-service configuration plans. It’ll be a while until it is ready.

0reactions
ejona86commented, Mar 31, 2017

@odiszapc, there is no default deadline if one is not set. It is the equivalent of “infinite.”

@beninu, the timeout on the server is known to be imprecise, because any precise solution would require a lot of infrastructure. The server’s view of the deadline will not be before the client’s view (other than cases of extreme clock speed differences). But we handle the various cases, best-effort.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Meet a Deadline - Delivering Timely Results - Mind Tools
To encourage a smooth flow of work. Deadlines help us to collaborate toward achieving a shared goal, and to keep complex, multistage projects...
Read more >
Why Deadlines Are Important | Indeed.com
When you're creating a deadline, you need to decide on the time that you give yourself to complete a certain task. This basically...
Read more >
8 Tips on How to Meet Deadlines Without Over-Stressing ...
8 tips to meet your deadlines · 1 Communicate a clear deadline · 2 Break down the project · 3 Have a start...
Read more >
Deadlines: How Effective Time Constraints Can Boost ...
The key benefit of deadlines is that they prompt people to take action in a timely manner through various mechanisms, such as making...
Read more >
Why Are Deadlines Important? (9 Essential Reasons)
Deadlines hold you accountable to finish your work within the required timeframe. Without deadlines, either voluntary or provided to you by someone else,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found