MySQL 클러스터(Cluster)가 논클러스터(non-Cluster) 보다 느립니다.

sangheon의 이미지

총 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개인데다가 데이터가 메모리에 있기 때문에 훨씬 빠를 것이라고 예상했는데 정반대의 결과가 나와서 당황하고 있습니다.

클러스터가 느린 것이 맞는지, 아니면 틀린거나 의심되는 설정 부분이 있으면 지적부탁드립니다.

감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.