Browse code

Fix rate limiting for logger, increase refill rate

Signed-off-by: Ethan Mosbaugh <ethan@replicated.com>
(cherry picked from commit 50c6a5fb07c873fd5c9ae3fb6294e0b11c689de2)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Ethan Mosbaugh authored on 2019/06/13 05:48:36
Showing 1 changed files
... ...
@@ -508,7 +508,9 @@ func (r *controller) Logs(ctx context.Context, publisher exec.LogPublisher, opti
508 508
 	var (
509 509
 		// use a rate limiter to keep things under control but also provides some
510 510
 		// ability coalesce messages.
511
-		limiter = rate.NewLimiter(rate.Every(time.Second), 10<<20) // 10 MB/s
511
+		// this will implement a "token bucket" of size 10 MB, initially full and refilled
512
+		// at rate 10 MB tokens per second.
513
+		limiter = rate.NewLimiter(10<<20, 10<<20) // 10 MB/s
512 514
 		msgctx  = api.LogContext{
513 515
 			NodeID:    r.task.NodeID,
514 516
 			ServiceID: r.task.ServiceID,