So, I’d probably start with a bounded queue and a limited number of workers, so incoming load cannot create an unbounded number of goroutines.
From there, I’d set a separate concurrency limit for each downstream dependency, propagate cancellation and deadlines through context, and retry only idempotent operations with backoff and jitter.
group, ctx := errgroup.WithContext(ctx)group.SetLimit(maxWorkers)for _, job := range jobs { job := job group.Go(func() error { return process(ctx, job) })}return group.Wait()
If the queue fills up, I’d apply backpressure by rejecting or deferring work instead of adding more workers.
I’d tune the limits using queue depth, saturation, latency, and error-rate metrics, and then verify them under load.