Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
harden redis and sync service. (#712)
* harden redis and sync service. * increase default sync service redis pool size from `runtime.NumCPU()*10` (default) to `8192` to prevent starvation. * Starvation is very probable in the sidecar, given that we use the XREAD primitive, which blocks a connection. * The sidecar is especially exposed to this, as it is a single process that accumulates a lot of `XREAD` blocked conns to receive network change requests from instances. * `8192` is a suitable value because on `local:docker`, we won't run as many containers, and on `cluster:k8s`, sidecars only handle containers colocated on the node. * increase ulimits on infra containers to 1M open file descriptors. * expose pprof port of sidecar; enable GC traces for debuggability. * upgrade to go-redis v7.2.0. additionally: harden throttling logic in local:docker runner. * address review comment.
- Loading branch information
Showing
9 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package sync | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"sync" | ||
"testing" | ||
) | ||
|
||
func BenchmarkBarrier(b *testing.B) { | ||
b.ReportAllocs() | ||
|
||
close := ensureRedis(b) | ||
defer close() | ||
|
||
runenv := randomRunEnv() | ||
|
||
watcher, writer := MustWatcherWriter(context.Background(), runenv) | ||
defer watcher.Close() | ||
defer writer.Close() | ||
|
||
target := 1000000 | ||
workers := 10 | ||
each := target / workers | ||
|
||
for n := 0; n < b.N; n++ { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
state := State(fmt.Sprintf("yoda-%d", n)) | ||
|
||
var wg sync.WaitGroup | ||
for i := 0; i < workers; i++ { | ||
wg.Add(1) | ||
go func(start, end int) { | ||
defer wg.Done() | ||
|
||
for i := start; i < end; i++ { | ||
writer.SignalEntry(ctx, state) | ||
} | ||
}(i*each, (i+1)*each) | ||
} | ||
|
||
b.ResetTimer() | ||
ch := watcher.Barrier(ctx, state, int64(target)) | ||
<-ch | ||
cancel() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters