• Do not allocate objects and []byte buffers - just reuse them as much

    as possible. Fasthttp API design encourages this.

    in production.

    go tool pprof --alloc_objects your-program mem.pprof usually gives better

    insights for optimization opportunities than go tool pprof your-program cpu.pprof.

    • Write tests and benchmarks for hot paths.
    • Avoid conversion between []byte and string, since this may result in memory

    allocation+copy. Fasthttp API provides functions for both []byte and string -

    use these functions instead of converting manually between []byte and string.

    There are some exceptions - see this wiki page

    for more details.

    • Verify your tests and production code under

    race detector on a regular basis.

    html/template in your webserver.