valyala/fasthttp · warning
cannot compress data due to high load
Error message
cannot compress data due to high load
What it means
errHighLoad (unexported, in stackless/writer.go) is returned by the stackless compressor's do function when the system is under high load and it cannot afford to compress data. The stackless package conserves stack/allocations and backs off compression rather than exhausting resources.
Source
Thrown at stackless/writer.go:108
func (w *writer) do(op op) error {
w.op = op
if !stacklessWriterFunc(w) {
return errHighLoad
}
err := w.err
if err != nil {
return err
}
if w.xw.bb != nil && len(w.xw.bb.B) > 0 {
_, err = w.dstW.Write(w.xw.bb.B)
}
w.xw.Reset()
return err
}
var errHighLoad = errors.New("cannot compress data due to high load")
var (
stacklessWriterFuncOnce sync.Once
stacklessWriterFuncFunc func(ctx any) bool
)
func stacklessWriterFunc(ctx any) bool {
stacklessWriterFuncOnce.Do(func() {
stacklessWriterFuncFunc = NewFunc(writerFunc)
})
return stacklessWriterFuncFunc(ctx)
}
func writerFunc(ctx any) {
w := ctx.(*writer) //nolint:forcetypeassert
switch w.op {
case opWrite:
w.n, w.err = w.zw.Write(w.p)View on GitHub (pinned to c96f600972)
Solutions
- Reduce overall load (throttle requests, add backpressure) so compression can proceed.
- Disable or lower compression usage when under high load.
- Retries: the error is transient; retry the write once load drops.
Example fix
// before
if err := sw.Flush(); err != nil { return err } // may be errHighLoad
// after
if err := sw.Flush(); err != nil {
if errors.Is(err, errHighLoad) { /* shed load or retry later */ }
return err
} Defensive patterns
Strategy: retry
Validate before calling
// no pre-validation possible: errHighLoad is produced internally under load // mitigate by limiting concurrent compressing writers beforehand
Try / catch
if err := sw.Flush(); err != nil {
if strings.Contains(err.Error(), "high load") {
time.Sleep(backoff)
// retry once load decreases
}
return err
} Prevention
- Throttle concurrent compression work to keep system load low.
- Treat this error as transient: retry with backoff.
- Consider bypassing compression under high load.
- Monitor CPU/alloc pressure to predict compression backoff.
When it happens
Trigger: Writing compressed output through the stackless writer while its load guard indicates high load; do() returns errHighLoad instead of compressing.
Common situations: Servers under heavy CPU/alloc pressure with compression enabled; small stacks / constrained environments where stackless compression backs off.
Related errors
- brotli: excessive input
- seek is not implemented
- fasthttp: unsupported content-encoding
- cannot create temporary file for %q: %w
- error when compressing file %q to %q: %w
AI-assisted analysis of valyala/fasthttp@c96f600972 (2026-08-31).
Data as JSON: /api/errors/55e3b9f7a09ac2c6.
Report an issue: GitHub.