2010. 10. 3.

[MySQL]Too Many Connection Error

show variables like '%timeout%';
show variables like '%connect%';
show variables like '%thread%';

show status like '%thread%';
show status like '%connect%';

======================================================================

show status like 'Threads_created';
show status like 'Connections';
Cache Miss Rate(%) =  Threads_created / Connections * 100

show status like 'Aborted_connects';
show status like 'Connections';
Connection Miss Rate(%) = Aborted_connects / Connections * 100

show status like 'Threads_connected';
show variables like 'max_connections';
Connection Usage(%) = Threads_connected / max_connections * 100

show status like 'Max_used_connections';

==========================================================================

Connection Usage가 100%면 max_connections 수를 증가시켜야 한다.
Connection Miss Rate 가 1%이상이면 wait_timeout을 더 길게 설정해야한다.
Cache Miss Rate가 높다면 thread_cache_size를 더 높게 잡아야 한다.

Max_used_connections 에서는 그 동안 사용되었던 최대 커넥션 수를 보여준다.

나의 경우는 Cache Miss Rate가 100%에 가깝게 나왔다.
그건 thread_cache_size가 0이기 때문에 매번 쓰레드를 생성해서이다.
일반적으로 Peak-time의 threads_connected보다 약간 낮은 수치로 설정하는 것이 좋습니다.

SET GLOBAL thread_cache_size = 40;

이렇게 값을 세팅해주었고, Cache Miss Rate 가 줄어들길 기다려야겠다.


댓글 없음:

댓글 쓰기