2023.01.25 - [๐ŸŒ ์ธํ”„๋ผ/NHN Cloud] - NHN Cloud ์ธ์Šคํ„ด์Šค์— Redis ์„ค์น˜ํ•˜๊ธฐ (1) - ์••์ถ•ํŒŒ์ผ ์ด์šฉ

2023.02.08 - [๐Ÿ’ป ํ”„๋กœ๊ทธ๋ž˜๋ฐ/Shell] - Redis ์„ค์น˜ ์ž๋™ํ™” ์Šคํฌ๋ฆฝํŠธ (1) - binary ๋ฐฉ์‹

 

์œ„์˜ ํฌ์ŠคํŒ…์„ ์ด์šฉํ•ด์„œ Redis๋ฅผ ์„ค์น˜ํ–ˆ์„ ๋•Œ ์ดˆ๊ธฐ ์‹คํ–‰ ํ™”๋ฉด์ž…๋‹ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ ๋ญ”๊ฐ€ ๊น”๋”ํ•˜์ง€ ์•Š๊ณ  ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฉ”์‹œ์ง€๋“ค์ด ๋– ์žˆ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

 

๊ตฌ๊ธ€๋ง์„ ํ•˜๋ฉด ๊ธˆ๋ฐฉ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์–ด๋–ค ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๋Š”์ง€ ํ•œ๋ฒˆ ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ฉ”์‹œ์ง€๋ฅผ ์ฝ์–ด๋ณด๋ฉด ์–ด๋–ค ๋‚ด์šฉ์ธ์ง€, ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ๋˜๋Š”์ง€ ์นœ์ ˆํ•˜๊ฒŒ ์ ํ˜€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ•˜๋‚˜์”ฉ ์ง„ํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

 

์„ค์น˜ ํ™˜๊ฒฝ

  • NHN Cloud
  • CentOS 7.9
  • Redis 7.0.11

 

1. config ํŒŒ์ผ ์ง€์ •

  • ๋ฌธ์ œ
Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf

warning ๋ฉ”์‹œ์ง€ ๊ทธ๋Œ€๋กœ config ํŒŒ์ผ์ด ์„ธ๋ถ€์ ์œผ๋กœ ์ง€์ •๋˜์–ด ์žˆ์ง€ ์•Š์•„์„œ default config๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

  • ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

๋ฉ”์‹œ์ง€์—์„œ ์•Œ๋ ค์ฃผ๋Š”๋Œ€๋กœ ์•„๋ž˜์ฒ˜๋Ÿผ config ํŒŒ์ผ์„ ์ง€์ •ํ•ด์„œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

src/redis-server redis.conf

 

 

2. TCP backlog ์„ค์ •๊ฐ’ ์˜ค๋ฅ˜

  • ๋ฌธ์ œ
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

๋ฆฌ๋ˆ…์Šค ์„ค์ •(/proc/sys/net/core/somaxconn)์€ 128๋กœ ๋˜์–ด ์žˆ๋Š”๋ฐ redis.conf์˜ TCP backlog๋Š” 511๋กœ ์„ค์ •๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฆฌ๋ˆ…์Šค ์„ค์ • ๊ฐ’์„ ์ฆ๊ฐ€ํ•˜๋ผ๋Š” ๋ฉ”์‹œ์ง€์ž…๋‹ˆ๋‹ค.

 

  • backlog๋ž€? ๋ฌผ๋ฆฌ์  ๋„คํŠธ์›Œํฌ ํฌํŠธ์—์„œ ํŒจํ‚ท์„ ์Œ“์•„๋‘๋Š” ์ปค๋„์˜ ํ ํฌ๊ธฐ
  • TCP backlog๋ž€? Redis ์„œ๋ฒ„์˜ ์ดˆ๋‹น ํด๋ผ์ด์–ธํŠธ ์—ฐ๊ฒฐ ์ˆ˜
  • somaxconn์ด๋ž€? socket max connection์˜ ์•ฝ์ž๋กœ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ์ตœ๋Œ€ ์ˆ˜
  • somaxconn ๊ฐ’ ํ™•์ธํ•˜๊ธฐ
$ sysctl -a | grep somaxconn
net.core.somaxconn = 128

 

  • ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

sysctl.conf ํŒŒ์ผ์˜ somaxconn ๊ฐ’์„ ๋ณ€๊ฒฝํ•ด์ค๋‹ˆ๋‹ค.

$ sudo vi /etc/sysctl.conf
net.core.somaxconn = 4096

 

์„ค์ •์ด ์˜๊ตฌ์ ์œผ๋กœ ์ ์šฉ๋˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ธ์Šคํ„ด์Šค๋ฅผ ์žฌ๋ถ€ํŒ…ํ•˜๊ฑฐ๋‚˜ ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์ค๋‹ˆ๋‹ค.

$ sudo sysctl net.core.somaxconn=4096

 

 

3. Memory overcommit ๋ฏธ์„ค์ •

  • ๋ฌธ์ œ
WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Memory overcommit์ด ๋ฐ˜๋“œ์‹œ ์‹คํ–‰๋˜์–ด์•ผ ํ•œ๋‹ค๊ณ  ์ ํ˜€์žˆ์Šต๋‹ˆ๋‹ค. 

๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋ถ€์กฑํ•˜๋ฉด ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ €์žฅ์ด๋‚˜ ๋ณต์ œ๊ฐ€ ์‹คํŒจํ•  ์ˆ˜ ์žˆ๊ณ , ์žฅ์• ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

  • ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

sysctl.conf ํŒŒ์ผ์˜ vm.overcommit_memory ๊ฐ’์„ 1๋กœ ๋ณ€๊ฒฝํ•ด์ค๋‹ˆ๋‹ค.

$ sudo vi /etc/sysctl.conf
vm.overcommit_memory = 1

 

์„ค์ •์ด ์˜๊ตฌ์ ์œผ๋กœ ์ ์šฉ๋˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ธ์Šคํ„ด์Šค๋ฅผ ์žฌ๋ถ€ํŒ…ํ•˜๊ฑฐ๋‚˜ ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์ค๋‹ˆ๋‹ค.

$ sudo sysctl vm.overcommit_memory=1

 

 

 

๊ฒฐ๊ณผ

warning ๋ฉ”์‹œ์ง€ ์—†์ด ๊น”๋”ํ•˜๊ฒŒ ์‹คํ–‰๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

 

+ Recent posts