Create a gist now

Instantly share code, notes, and snippets.

@methane /README.md
Last active Dec 16, 2015

What would you like to do?
commit trx/sec を計測

AWS RDS の commit / sec 測定

測定環境

RDS m2.4xlarge EC2 c1.medium

一番性能出てた時は、 EC2 の CPU の idle が 30% 切っていたので、クライアントの性能が若干不足している可能性あり。

write_io_threads=4, support_xa=1

$ time python rdshakai.py 1000 200
19.4682958126 [sec] 10273.1128562 [trx/sec]

write_io_threads=16, support_xa=1

$ time python rdshakai.py 1000 200
17.5357458591 [sec] 11405.2747802 [trx/sec]

write_io_threads=4, support_xa=0

$ time python rdshakai.py 500 200
5.81748700142 [sec] 17189.5528044 [trx/sec]

write_io_threads=16, support_xa=0

$ time python rdshakai.py 1000 200
9.90894699097 [sec] 20183.7793847 [trx/sec]
CREATE TABLE `bench` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`val` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB
#!/usr/bin/env python
import umysql
DB_HOST = 'localhost'
DB_USER = 'benchmark'
DB_PASS = 'benchmark'
DB_DB = 'benchmark'
N = 1
def connect(autocommit=True):
con = umysql.Connection()
con.connect(DB_HOST, 3306, DB_USER, DB_PASS, DB_DB, autocommit)
return con
def hakai(id, autocommit=True, n=1000):
con = connect(autocommit)
sql = "update bench set val=val+1 where id=%d" % (id,)
for _ in xrange(N):
con.query(sql)
if not autocommit:
con.commit()
con.close()
def prepare(c):
con = connect()
con.query("TRUNCATE TABLE bench")
for id in xrange(c):
con.query("insert into bench (id, val) values (%d, 0)" % (id+1,))
con.close()
def main():
global N
import multiprocessing
import time
c, N = 1, 1
import sys
if len(sys.argv) > 1:
N = int(sys.argv[1])
if len(sys.argv) > 2:
c = int(sys.argv[2])
prepare(c)
pool = multiprocessing.Pool(c)
t = time.time()
pool.map(hakai, range(1, c+1))
t = time.time() - t
print("%s [sec] %s [trx/sec]" % (t, (c*N)/t))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment