Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRPC TTFB Determination clarity #503

Open
mjones713 opened this issue Jan 13, 2025 · 2 comments
Open

GRPC TTFB Determination clarity #503

mjones713 opened this issue Jan 13, 2025 · 2 comments

Comments

@mjones713
Copy link

mjones713 commented Jan 13, 2025

When executing grpcurl command and using "-vv" command I notice this output:

Response trailers received:
(empty)
Sent 1 request and received 1 response
Timing Data: 1.336617959s
Dial: 663.003042ms
TLS Setup: 4.083µs
BlockingDial: 662.955083ms
InvokeRPC: 520.699667ms

ChatGPT mentioned the following:

InvokeRPC:

  • Represents the time taken to send the request and receive the first byte of the response (TTFB).

  • This is equivalent to Time to First Byte.

InvokeRPC measures the duration between when the RPC request is sent and the first meaningful data is received from the server.
This includes the server processing time and any network latency after the connection is established.

So the question we're needing clarity is; In the example above InvokeRPC: 520.699667ms. Does the 520ms represent the 1st byte received or when the full response returned?

@jhump
Copy link
Contributor

jhump commented Jan 14, 2025

@mjones713, "InvokeRPC" is the entire RPC duration. So it includes the time to both upload all of the request bytes and download all of the response bytes.

If we were to expand the timing data to be more granular, the likely best that could be done is "time to first message" (and include time to download the entire initial message). But that wouldn't really be an improvement for unary and client-stream RPCs, which only ever have one response message. And it's of questionable value for bidirectional streams (or at least unclear exactly how to measure/interpret it), since the first response message could actually arrive before any request message is sent.

Unfortunately, the grpc-go library that this tool uses does not provide visibility into "time to first byte". The tool doesn't currently install a stats.Handler to collect more fine-grained data. But even if it did, the message receipt timestamps are for when an entire message is received in its entirety; no information is provided about when the first byte/packet was received.

@mjones713
Copy link
Author

Thanks @jhump for your detailed response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants