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

Document Server.ServeHTTP #1406

Merged
merged 1 commit into from
Aug 7, 2017
Merged

Document Server.ServeHTTP #1406

merged 1 commit into from
Aug 7, 2017

Conversation

bradfitz
Copy link
Contributor

Fixes #549

@bradfitz
Copy link
Contributor Author

/cc @dfawley

@puellanivis
Copy link

I don’t find this documentation actually any more clear. I think more harnessing of the example might be important. Where is this code snippet supposed to go? How am I supposed to get yourMux? etc.

It still seems like the code is written towards people who already know how the functionality works, and doesn’t need all the “magic” spelled out for them.

@geoffgarside
Copy link

The yourMux is just another http.Handler, so whatever would handle your non grpc requests. You might create it from http.NewServeMux() or any of the various http router packages that are available.

You'd probably have this snippet inside some kind of request director ServeHTTP() or http.HandlerFunc middleware.

@puellanivis
Copy link

I don’t think putting said explanation here or in a FAQ would be documenting the code clearly.

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is helpful. Could we add a disclaimer to this docstring, as well? Something like:

This functionality is experimental and unsupported.  Serving gRPC
through another HTTP server prevents some gRPC features from
working, and may impact performance significantly.

@dfawley
Copy link
Member

dfawley commented Jul 31, 2017

I think the docstring here is sufficient to at least point users toward the http package so they can figure out the rest. If more help is necessary, a user manual or examples would be more appropriate IMO. Although, TBH, with the downsides of this method of serving, I would like to discourage its use by all but the biggest power users that already know how this stuff works.

#549 did specifically mention adding usage examples. @bradfitz, do you still have the examples referenced in #549?:

The examples were removed from earlier versions of #514 to reduce the size of that change.

Thanks!

@bradfitz
Copy link
Contributor Author

I would prefer it as-is without the FUD. The words "may" and "significantly" in your proposed addition are at opposite sides of the certainly spectrum.

If you want to cite actual features they'll lose, that's fine. But which?

@dfawley
Copy link
Member

dfawley commented Jul 31, 2017

The words "may" and "significantly" in your proposed addition are at opposite sides
of the certainly spectrum.

I don't see these as opposites. "May" describes certainty, while "significantly" describes severity.

If you want to cite actual features they'll lose, that's fine. But which?

Keepalive, keepalive enforcement (ping flood prevention), max connection age and idleness detection, flow control settings and optimizations (e.g. BDP estimation and large message optimizations), stream-level flow control tied to application reads, GracefulStop(), InTapHandle(), stats hooks, status details, and possibly others.

I'd rather keep the FUD levels high here until such time that this path is well-understood and well-supported by the maintainers, which is currently not the case.

@bradfitz
Copy link
Contributor Author

What is "keepalive"? Go's HTTP/2 server keeps connections alive too, by default.

We also have idle timeouts (https://tip.golang.org/pkg/net/http/#Server ... https://tip.golang.org/pkg/net/http/#Server.IdleTimeout)

We don't do BDP estimation, that's true.

If you want a caveat, I'd prefer a caveat emptor wording that says it's a different HTTP/2 server implementation and "performance and available features may vary", without saying ServeHTTP "may" only suck more. I'd argue in a number of ways that Go's http2 server is more solid.

@bradfitz
Copy link
Contributor Author

I've pushed an addition with a possible caveat paragraph:

25d5150

@puellanivis
Copy link

I like the documentation a lot more now. 👍

@dfawley dfawley self-assigned this Aug 4, 2017
@dfawley
Copy link
Member

dfawley commented Aug 7, 2017

What is "keepalive"? Go's HTTP/2 server keeps connections alive too, by default.

Settings in gRPC to control pings to check liveness (ref), and matching server enforcement rules.

Even if the http2 package supports idle timeouts, we aren't configuring them right now in gRPC. And AIUI, we (within gRPC) can't if we're going through the ServeHTTP method of serving, because we don't have access to the server itself with this mechanism -- unless we hijack the net.Conn away from the server?

ServeHTTP "may" only suck more. I'd argue in a number of ways that Go's http2 server is more solid.

I'm not making any value judgments. But for now, the team is working almost exclusively on the gRPC transport, not the http2 one. We've repeatedly heard that performance is a problem with gRPC through a handler, but we haven't had time to look into this, nor do I expect we will in the next quarter or two. So for now I'd rather lead people (strongly) toward using our server. If our server 1 year from now just fires up x/net/http2, then that would be great, but that is not the current state of things.

I'm OK with the text of the paragraph that is there, but I would like to add a sentence to let people know it is not ("well"?) supported right now.

@dfawley
Copy link
Member

dfawley commented Aug 7, 2017

@bradfitz asked me to finish this off, as he won't have enough cycles to do so personally. I'll submit it and add the extra sentence I was requesting. Thanks for the PR.

@dfawley dfawley merged commit 383b114 into grpc:master Aug 7, 2017
@menghanl menghanl added 1.6 Type: Documentation Documentation or examples labels Aug 24, 2017
@dfawley dfawley modified the milestone: 1.6 Release Aug 28, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Documentation Documentation or examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants