Throttling bandwidth with Go

Imagine a service that is serving big log files over raw TCP, you decided to implement simple QoS for an existing server.

The goal of the task is to create small Go package that would allow for throttling bandwidth for TCP connections.


  • keep it simple
    • think of it as open-source software that builds upon existing solutions
  • use only stdlib and/or supplementary repositories (*)
  • the package should allow for:
    • setting one cumulative bandwidth limit for all connections* (aka global limit)
    • setting single individual bandwidth limit for all connections** (aka connection limit)
    • changing limits in runtime (applies to all existing connections)
  • for a 30s transfer sample consumed bandwidth should be accurate +/- 5%

Reasonable deadline for submitting a solution is 8 days. Questions, clarifications – please drop us an e-mail!


go test -v -timeout 300s

Example server usage

    l, err := net.Listen("tcp", addr)
    if err != nil {
    for {
        conn, err := l.Accept()
        if err != nil {
        wrappedConn := limiter.WrapConn(conn)
        go handleConn(t, wrappedConn)


View Github