-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: check os file descriptor limit and num cpus
Logs a warning if numbers below acceptable levels. ``` [Mar 2 18:36:55] WARN File descriptor limit 4864 too low for production use. Min 80000 recommended. This could have a significant negative impact on performance. Please refer to https://tyk.io/docs/deploy-tyk-premise-production/#file-handles for further guidance. [Mar 2 18:36:55] WARN Num CPU(s) 1 too low for production use. Min 2 recommended. This could have a significant negative impact on performance. Please refer to https://tyk.io/docs/deploy-tyk-premise-production/#use-the-right-hardware for further guidance. ```
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package checkup | ||
|
||
import ( | ||
"runtime" | ||
"syscall" | ||
|
||
logger "github.com/TykTechnologies/tyk/log" | ||
) | ||
|
||
var log = logger.Get() | ||
|
||
const ( | ||
minCPU = 2 | ||
minFileDescriptors = 80000 | ||
) | ||
|
||
func CheckFileDescriptors() { | ||
|
||
rlimit := &syscall.Rlimit{} | ||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, rlimit) | ||
if err == nil && rlimit.Cur < minFileDescriptors { | ||
log.Warningf("File descriptor limit %d too low for production use. Min %d recommended.\n"+ | ||
"\tThis could have a significant negative impact on performance.\n"+ | ||
"\tPlease refer to https://tyk.io/docs/deploy-tyk-premise-production/#file-handles for further guidance.", rlimit.Cur, minFileDescriptors) | ||
} | ||
} | ||
|
||
func CheckCpus() { | ||
|
||
cpus := runtime.NumCPU() | ||
if cpus < minCPU { | ||
log.Warningf("Num CPUs %d too low for production use. Min %d recommended.\n"+ | ||
"\tThis could have a significant negative impact on performance.\n"+ | ||
"\tPlease refer to https://tyk.io/docs/deploy-tyk-premise-production/#use-the-right-hardware for further guidance.", cpus, minCPU) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters