Skip to content

Commit

Permalink
Disabling GC at handler level
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfireman committed Aug 10, 2018
1 parent 25ac584 commit 39ecb71
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions httphandler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"runtime"
"runtime/debug"
)

const (
Expand All @@ -14,6 +15,8 @@ const (
// GCI returns the GCI HTTP handler, which controls Go's GC to decrease service tail latency.
// Ideally, GCI handler should be the first middleware in the service process chain.
func GCI(next http.HandlerFunc) http.HandlerFunc {
debug.SetGCPercent(-1)
fmt.Println("==< Automatic GC Disabled <==")
return func(w http.ResponseWriter, r *http.Request) {
switch r.Header.Get(gciHeader) {
case "":
Expand Down

0 comments on commit 39ecb71

Please sign in to comment.