Post

TroubleShooting_Too many Connections

โœ… 500 Error on frontend

Although everything was running just fine on postman, when connecting with frontend, there was a 500 error.

image

image

Screenshot 2024-06-20 at 21 53 50

๐Ÿ”ต Check Max connections, wait_timeout

Go into Ubuntu then,

1
mysql -h drugstoredb.cn000owqib3s.ap-northeast-2.rds.amazonaws.com -u root -p
1
show variables like "%max_connections%";

Screenshot 2024-06-20 at 14 39 48

1
show status like "%connect%";

Screenshot 2024-06-20 at 14 39 52

1
show status like '%thread%';

Screenshot 2024-06-20 at 14 54 10

1
show variables like '%timeout%';

Screenshot 2024-06-20 at 15 11 32

๋‚˜์˜ ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ˆ˜์น˜๊ฐ€ ๋‚˜์™”๋‹ค.

  • Cache Miss Rate= 2.40%
  • Connection Miss Rate= 17%
  • Connection Usage= 53%

๋”ฐ๋ผ์„œ

  • wait_timeout = 180
  • max_connections = 300 ์œผ๋กœ ์„ค์ •ํ•˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.

๐Ÿ”ต Change connections, timeout

โœ”๏ธ AWS parameter

RDS์˜ parameter ๋ฐ”๊ฟ”์ฃผ๊ธฐ https://cha-vi.tistory.com/56

์„ค์ • ์ดํ›„ show variables like "%max_connections%"; ํ•ด๋ณด๋ฉด ๋‚ด๊ฐ€ ๋ฐ”๊พผ ์ˆซ์ž๋กœ ์ž˜ ๋‚˜์˜ค๋Š” ๊ฒƒ ํ™•์ธ ๊ฐ€๋Šฅ

โœ”๏ธ ubuntu mariaDB

  1. Install mariaDB service
1
2
3
4
5
sudo apt update
sudo apt install mariadb-server

sudo systemctl start mariadb.service

  1. Change config file
1
2
cd /etc/mysql/mariadb.conf.d/
sudo nano 50-server.cnf
1
2
3
[mysqld]
max_connections = 300
wait_timeout = 180
  1. Restart mariaDB server
1
sudo systemctl restart mariadb.service

Screenshot 2024-07-15 at 12 08 22

๐Ÿ’ก ์ฐธ๊ณ ์ž๋ฃŒ

๐Ÿ”ต Check server.log

์ง€๊ธ‹์ง€๊ธ‹ํ•˜๋˜ too many connections๊ฐ€ ์‚ฌ๋ผ์กŒ๋‹ค! ๊ทธ๋ฆฌ๊ณ  ์—ฌ๋Ÿฌ๋ช…์ด ๋™์‹œ์— ์ ‘์†ํ•ด๋„ ์ž˜ ์ž‘๋™ํ•œ๋‹ค.

Screenshot 2024-07-15 at 11 57 48

Screenshot 2024-06-20 at 21 56 52

This post is licensed under CC BY 4.0 by the author.