Introduce a fast proxy mode to improve HTTP/1.1 performances with backends
Co-authored-by: Romain <rtribotte@users.noreply.github.com> Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
parent
a6db1cac37
commit
f8a78b3b25
39 changed files with 3173 additions and 378 deletions
29
pkg/proxy/httputil/bufferpool.go
Normal file
29
pkg/proxy/httputil/bufferpool.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package httputil
|
||||
|
||||
import "sync"
|
||||
|
||||
const bufferSize = 32 * 1024
|
||||
|
||||
type bufferPool struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
func newBufferPool() *bufferPool {
|
||||
b := &bufferPool{
|
||||
pool: sync.Pool{},
|
||||
}
|
||||
|
||||
b.pool.New = func() interface{} {
|
||||
return make([]byte, bufferSize)
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *bufferPool) Get() []byte {
|
||||
return b.pool.Get().([]byte)
|
||||
}
|
||||
|
||||
func (b *bufferPool) Put(bytes []byte) {
|
||||
b.pool.Put(bytes)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue