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

Periodically flush the reverse proxy #11759

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion pkg/kubectl/proxy_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/url"
"regexp"
"strings"
"time"

"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/golang/glog"
Expand All @@ -36,6 +37,16 @@ const (
DefaultMethodRejectRE = "POST,PUT,PATCH"
)

var (
// The reverse proxy will periodically flush the io writer at this frequency.
// Only matters for long poll connections like the one used to watch. With an
// interval of 0 the reverse proxy will buffer content sent on any connection
// with transfer-encoding=chunked.
Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO: about looking into the proxy to see if we can fix this without always adding 100ms of latency.

// TODO: Flush after each chunk so the client doesn't suffer a 100ms latency per
// watch event.
ReverseProxyFlushInterval = 100 * time.Millisecond
)

// FilterServer rejects requests which don't match one of the specified regular expressions
type FilterServer struct {
// Only paths that match this regexp will be accepted
Expand Down Expand Up @@ -171,7 +182,7 @@ func newProxy(target *url.URL) *httputil.ReverseProxy {
req.URL.Host = target.Host
req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path)
}
return &httputil.ReverseProxy{Director: director}
return &httputil.ReverseProxy{Director: director, FlushInterval: ReverseProxyFlushInterval}
}

func newFileHandler(prefix, base string) http.Handler {
Expand Down