nginx upstream keepalive는 다음을 설정한다.
keepalive – The number of idle keepalive connections to an upstream server that remain open for each worker process. There is no default value.
Syntax: | keepalive |
---|---|
Default: | — |
Context: | upstream |
This directive appeared in version 1.1.4.
Activates the cache for connections to upstream servers.
The connections
parameter sets the maximum number of idle keepalive connections to upstream servers that are preserved in the cache of each worker process. When this number is exceeded, the least recently used connections are closed.
It should be particularly noted that thekeepalive
directive does not limit the total number of connections to upstream servers that an nginx worker process can open. Theconnections
parameter should be set to a number small enough to let upstream servers process new incoming connections as well.
When using load balancing methods other than the default round-robin method, it is necessary to activate them before the keepalive
directive.
업스트림 서버에 연결할 캐시를 활성화한다. 연결 매개변수(connections 값)는 각 작업자 프로세스의 캐시에 보존되는 업스트림 서버에 대한 최대 유휴 유지 접속 수를 설정한다. 이 숫자를 초과하면 가장 최근에 사용한 연결이 닫힌다.
worker process당 설정 값인데, worker process는 cpu 코어 숫자이고 nginx 설정(conf 파일)을 보면 기본적으로 auto로 설정되어 있다.(worker_processes auto;)
auto로 되어있으면 시스템의 코어 숫자를 디텍팅하여 자동 설정된다.
코어 숫자 확인은 grep -c processor /proc/cpuinfo 명령어로 확인 가능하다.
아무튼 keepalive 숫자를 늘리면 서버가 처리할 수 있는 트래픽이 많아지는건 당연한거 같은데...서버 스펙 고려안하고 늘린다고 과연 다 받아줄지도 의문이고, 결국엔 커넥션 숫자를 늘리는게 아니라 서버를 증설하는 방향으로 갈거 같다.
댓글 없음:
댓글 쓰기