MySQL 클러스터(Cluster)가 논클러스터(non-Cluster) 보다 느립니다.
글쓴이: sangheon / 작성시간: 수, 2006/09/27 - 6:34오후
총 5대의 서버가 있습니다.
A - ndb node 1
B - ndb node 2
C - sql 1
D - sql 2
E - ndb_mgr, MySQL(innodb)
A~D 서버는 펜티엄 4 3.4G, 4G RAM 으로 성능이 동일합니다. E 서버는 AMD 옵테론 2G, 4G RAM 입니다. 각 서버들은 IDC에서 스위치를 통해 100 Mbps 로 연결되어 있습니다.
E 서버에는 innodb 타입의 MySQL 서버가 하나 더 설치되어 있습니다.
node 와 ndb_mgr 의 설정을 다음과 같습니다.
ndb node 의 my.cnf
# Options for mysqld process: [MYSQLD] ndbcluster # run NDB engine ndb-connectstring=xxx.xxx.xxx.126 # location of MGM node # Options for ndbd process: [MYSQL_CLUSTER] ndb-connectstring=xxx.xxx.xxx.126 # location of MGM node
ndb_mgr 의 config.ini
[NDBD DEFAULT] NoOfReplicas=2 # Number of replicas DataMemory=1600M # How much memory to allocate for data storage IndexMemory=400M # How much memory to allocate for index storage # For DataMemory and IndexMemory, we have used the # default values. Since the "world" database takes up # only about 500KB, this should be more than enough for # this example Cluster setup. # TCP/IP options: [TCP DEFAULT] portnumber=2202 # This the default; however, you can use any # port that is free for all the hosts in cluster # Note: It is recommended beginning with MySQL 5.0 that # you do not specify the portnumber at all and simply allow # the default value to be used instead # Management process options: [NDB_MGMD] hostname=xxx.xxx.xxx.126 # Hostname or IP address of MGM node datadir=/var/lib/mysql-cluster # Directory for MGM node logfiles # Options for data node "A": [NDBD] # (one [NDBD] section per data node) hostname=xxx.xxx.xxx.122 # Hostname or IP address datadir=/usr/local/mysql/data # Directory for this data node's datafiles # Options for data node "B": [NDBD] hostname=xxx.xxx.xxx.123 # Hostname or IP address datadir=/usr/local/mysql/data # Directory for this data node's datafiles # SQL node options: [MYSQLD] hostname=xxx.xxx.xxx.124 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore) [MYSQLD] hostname=xxx.xxx.xxx.125 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
ndb와 innodb 양쪽에 아래 형식의 테이블을 만들고 320843(32만) 건의 데이터를 각각 넣었습니다.
mysql> desc tbl_board; +------------------+----------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+----------------------+------+-----+---------------------+----------------+ | no | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | top_no | double unsigned | NO | MUL | 0 | | | idx | tinyint(4) | NO | | 0 | | | depth | tinyint(3) unsigned | NO | MUL | 0 | | | reply_from | bigint(20) | NO | | 0 | | | code | varchar(7) | NO | MUL | | | | category | varchar(4) | NO | | | | | adult | enum('Y','N') | NO | | Y | | | is_notice | tinyint(3) unsigned | NO | MUL | 2 | | | uid | int(10) unsigned | YES | MUL | NULL | | | nickname | varchar(20) | NO | | | | | subject | varchar(100) | NO | | | | | contents | text | NO | | | | | hit | int(11) | NO | | 0 | | | ip | varchar(15) | NO | | | | | date | datetime | NO | | 0000-00-00 00:00:00 | | | cnt_comment | smallint(5) unsigned | NO | | 0 | | | recm_point | smallint(6) | NO | | 0 | | | objt_point | smallint(6) | NO | | 0 | | | recm_count | smallint(5) unsigned | NO | | 0 | | | period | int(10) unsigned | NO | | 0 | | | temp | bigint(20) unsigned | NO | | 0 | | | cnt_reco_comment | smallint(5) unsigned | NO | | 0 | | +------------------+----------------------+------+-----+---------------------+----------------+ 23 rows in set (0.00 sec)
간단히 쿼리 시간을 측정하는 페이지를 만들어서 둘을 비교했습니다.
query = SELECT * FROM tbl_board WHERE no = 1592058 query execution time = 0.0027220249176 count = 0 query = SELECT * FROM tbl_board WHERE no = 1592058 query execution time = 0.000311851501465 count = 0
첫번째가 클러스터(ndb)이고 두번째가 논클러스터(innodb)입니다. 보시면 아시겠지만 쿼리 시간이 확연히 차이가 납니다. 풀스캔을 하는 쿼리의 경우 논클러스터가 5초 내외, 클러스터는 50초가 걸립니다.
클러스터는 노드도 2개인데다가 데이터가 메모리에 있기 때문에 훨씬 빠를 것이라고 예상했는데 정반대의 결과가 나와서 당황하고 있습니다.
클러스터가 느린 것이 맞는지, 아니면 틀린거나 의심되는 설정 부분이 있으면 지적부탁드립니다.
감사합니다.
Forums:
댓글 달기