🔥 make the fasthttp `ReduceMemoryUsage` flag public

This PR introduces the `ReduceMemoryUsage` flag to the server config
that is pulled to the underlying fasthttp server. The default is false
to keep the old behavior.

The implementation of `ReduceMemoryUsage` is here: 01acd76daf/server.go (L285)

Refs: #866 / https://github.com/gofiber/fiber/issues/866#issuecomment-704818583
pull/892/head
Roman 2020-10-07 11:55:17 +02:00
parent 61c891c565
commit 6084e7c1f1
1 changed files with 11 additions and 0 deletions

11
app.go
View File

@ -224,6 +224,16 @@ type Config struct {
// Default: false
DisableStartupMessage bool `json:"disable_startup_message"`
// Aggressively reduces memory usage at the cost of higher CPU usage
// if set to true.
//
// Try enabling this option only if the server consumes too much memory
// serving mostly idle keep-alive connections. This may reduce memory
// usage by more than 50%.
//
// Default: false
ReduceMemoryUsage bool `json:"reduce_memory_usage"`
// FEATURE: v2.2.x
// The router executes the same handler by default if StrictRouting or CaseSensitive is disabled.
// Enabling RedirectFixedPath will change this behaviour into a client redirect to the original route path.
@ -663,6 +673,7 @@ func (app *App) init() *App {
app.server.ReadBufferSize = app.config.ReadBufferSize
app.server.WriteBufferSize = app.config.WriteBufferSize
app.server.GetOnly = app.config.GETOnly
app.server.ReduceMemoryUsage = app.config.ReduceMemoryUsage
// unlock application
app.mutex.Unlock()