최대 동시접속자 수 테스트용 프로그램입니다.
컴파일 방법:
g++ -o mysql-con-stress -I/usr/local/mysql/include/mysql/ -L/usr/local/mysql/lib/mysql/ -lmysqlclient mysql-con-stress.cc
사용방법:
./mysql-con-stress host user pass max_tries
host : 예를 들면 localhost
user : root
pass : 암호
max_tries : 최대동시접속자 수
성공시:
Successefully established 1500 connections
Never failed
Cleaning up 1500 connections ...
Clean up complete
실패시:
Successefully established 1501 connections
Failed because Too many connections
Cleaning up 1501 connections ...
Clean up complete
MySQL Client 상에서 최대 동시접속 확인법:
show status like \max_used_connections\;
이 결과값이 max_tries와 일치하여야 함.
주의사항: mysql_connect 함수가 deprecate 되었으므로 mysql_real_connect 함수로 수정하였습니다. 자신의 MySQL버젼에서 오류가 발상할 경우 mysql_init() 부분을
삭제하고 mysql_real_connect 함수를 mysql_connect()함수로 수정바랍니다.
/*
* mysql-con-stress.cc by Sasha Pachev
* Stresses a running mysqld to see the maximum number of additional concurrent
* connections it can handle
* to compile: g++ -o mysql-con-stress -I<where_mysql.h_is_found> \r
-L<where-libmysqlclient-is-found> mysql-con-stress.cc -lmysqlclient
* to use: mysql-con-stress host user pass max_tries
* If the first three parameters are not obvious, you should not be using this program
* max_tries is the maximum number of concurrent connection mysql-con-stress will try to
* estabilsh
*/
#include <mysql.h>
#include <iostream.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
int num_cons = 0;
MYSQL* glob_cons = NULL;
void clean_up(int )
{
int i;
cerr << \Cleaning up \ << num_cons << \ connections ...\ << endl;
for(i = 0; i < num_cons; i++)
{
mysql_close(glob_cons + i);
}
cerr << \Clean up complete\ << endl;
exit(0);
}
void usage()
{
cerr << \Usage: mysql-con-stress host user pass max_tries\ << endl;
exit(1);
}
int main(int argc, char** argv)
{
if(argc != 5) usage();
char* user, *host, *pass;
int max_tries;
user = argv[2];
host = argv[1];
pass = argv[3];
max_tries = atoi(argv[4]);
MYSQL cons[max_tries];
glob_cons = cons;
int i;
int never_failed = 1;
int port = 0;
// if we get a signal, clean up first
signal(SIGTERM, clean_up);
signal(SIGINT, clean_up);
// establish as many connections as we can
for(i = 0; i < max_tries; i++)
{
mysql_init(&cons);
mysql_real_connect(cons + i, host, user, pass, \test\, 0, NULL, 0);
num_cons = i ;
if((mysql_error(cons + i))[0])
{
never_failed = 0;
cout << \Successefully established \ << num_cons << \ connections\ << \r
endl; cout << \Failed because \ << mysql_error(cons + i) << endl;
break;
}
}
if(never_failed)
{
num_cons = i ;
cout << \Successefully established \ << num_cons << \ connections\ << endl;
cout << \Never failed \ << endl;
}
// this is really not necessary, because exiting will close all the connection,
// but it is good practice to clean up
clean_up(0);
return 0;
}
출처 : http://database.sarang.net/?inc=read&criteria=mysql&subcrit=columns&aid=16454
팁과 해결
bibaram2006.03.24 · 5분 읽기 · 조회 3,735
mysql - 최대 동시접속자수 테스트 프로그램
bibaram2006.03.24 · 5분 읽기 · 조회 3,735이어서 읽기
팁과 해결↗
Synology 서비스 네트워크 포트
Synology 서비스는 어떤 네트워크 포트를 사용합니까? 다음 목록을 참조하십시오. 설정 유틸리티 유형 포트 번호 프로토콜 Synology Assistant 9999, 9998, 9997 UDP 백업 유형 포트 번호 프로토콜 Data Replicator…
2019.09.22·7분 읽기
팁과 해결↗
메일 리턴메세지 모음
아래의 첨부된 리턴 메시지를 참고하여 확인한다. Remote host said: 552 #5.3.4 message size exceeds limitremote host said: 550 sniper execeeds the limit size of email.상대 메일서버에서 받을 수 있는 메일…
2019.05.21·31분 읽기
팁과 해결↗
Diffi-Hellman key exchange
디피-헬만 키 교환이란 암호 키를 교환하는 방법이다. RSA와 마찬가지로 공통의 비밀키를 공유하기 위하여 만들어진 암호학적 통신 방법이다. RSA는 알다시피 암호화된 통신에서 공유될 비밀키를 공개키로 암호화하…
2018.02.22·3분 읽기
댓글 0
아직 댓글이 없습니다.