We've tried this before using libvmod-tbf during the Varnish3 era, and ended up backing it out over some pragmatic issues. The key issues were that:
- VCL reloads (which are very routine and constant) were leaking significant memory (in general, but specifically in the libvmod_tbf case it was the large TBF datasets)
- The TBF algorithm was structured such that the initial state on server start was "all buckets full" (no burst capacity), as opposed to assuming (at server start, or at seeing a new IP) that buckets are initially empty (in the virtual sense)
We need to resurrect this effort and get it deployed without such issues so that we can build other solutions on it.