Skip to content

Commit 80bf865

Browse files
committed
add concurrency
1 parent e63383b commit 80bf865

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

aws/logs_monitoring_go/internal/forwarding/forwarding.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import (
2626
)
2727

2828
const (
29-
maxLogSize = 1 * 1024 * 1024
30-
maxBatchSize = 5 * 1024 * 1024
31-
maxLogsPerBatch = 1000
29+
maxLogSize = 1 * 1024 * 1024
30+
maxBatchSize = 5 * 1024 * 1024
31+
maxLogsPerBatch = 1000
32+
maxBatchesInMemory = 12 // 12 * 5MiB = 60MiB maximum
3233
)
3334

3435
var bufPool = sync.Pool{
@@ -75,7 +76,7 @@ func (f *Forwarder) Start(ctx context.Context, in <-chan model.LogEntry, storage
7576
eg, ctx := errgroup.WithContext(ctx)
7677
eg.SetLimit(1 + httpclient.MaxConcurrency)
7778

78-
batches := make(chan json.RawMessage)
79+
batches := make(chan json.RawMessage, maxBatchesInMemory)
7980
eg.Go(func() error {
8081
defer close(batches)
8182
cfg := batching.NewConfig(maxLogSize, maxBatchSize, maxLogsPerBatch)

aws/logs_monitoring_go/internal/storing/sqs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (s *SQS) Store(ctx context.Context, batch Batch) error {
4545

4646
eg, ctx := errgroup.WithContext(ctx)
4747

48-
in := make(chan json.RawMessage)
48+
in := make(chan json.RawMessage, 10)
4949
eg.Go(func() error {
5050
defer close(in)
5151
for _, log := range logs {

0 commit comments

Comments
 (0)