日期:2014-05-16  浏览次数:20903 次

mysql打开log_bin后,并发写入无效了,多进程连接一起写和单进程写的时间一样长
关掉log_bin后,多进程并发写入时间明显加快,为什么

打开log_bin的情况 :

[root@liytest bin]# ./mysqlslap --concurrency=1,10,20,50,100 --number-of-queries 1000 --create-schema='test' --engine=innodb --query="insert into test7 values ('1111111111','1111111111','1111111111','1111111111','1111111111')" -h 192.168.2.56 -uroot -p
Enter password: 
Benchmark
  Running for engine innodb
  Average number of seconds to run all queries: 12.368 seconds
  Minimum number of seconds to run all queries: 12.368 seconds
  Maximum number of seconds to run all queries: 12.368 seconds
  Number of clients running queries: 1
  Average number of queries per client: 1000

Benchmark
  Running for engine innodb
  Average number of seconds to run all queries: 12.711 seconds
  Minimum number of seconds to run all queries: 12.711 seconds
  Maximum number of seconds to run all queries: 12.711 seconds
  Number of clients running queries: 10
  Average number of queries per client: 100


关闭log_bin

[root@liytest bin]# ./mysqlslap --concurrency=1,10,20 --number-of-queries 1000 --create-schema='test' --engine=innodb --query="insert into test7 values ('1111111111','1111111111','1111111111','1111111111','1111111111')" -h 192.168.2.56 -uroot -p
Enter password: 
Benchmark
  Running for engine innodb
  Average number of seconds to run all queries: 6.138 seconds
  Minimum number of seconds to run all queries: 6.138 seconds
  Maximum number of seconds to run all queries: 6.138 seconds
  Number of clients running queries: 1
  Average number of queries per client: 1000

Benchmark
  Running for engine innodb
  Average number of seconds to run all queries: 1.696 seconds
  Minimum number of seconds to run all queries: 1.696 seconds
  Maximum number of seconds to run all queries: 1.696 seconds
  Number of clients running queries: 10
  Average number of queries per client: 100

Benchmark
  Running for engine innodb
  Average number of seconds to run all queries: 1.433 seconds
  Minimum number of seconds to run all queries: 1.433 seconds
  Maximum number of seconds to run all queries: 1.433 seconds
  Number of clients running queries: 20
  Average number of queries per client: 50


难道打开log_bin后只能顺序写入,那还谈什么并发,那网站怎么使用,是不是有主配置啊

------解决方案--------------------
探讨

引用:
打开logbin会增加额外的写负载 虽然是顺序写


那是不是说打开logbin就只能是顺序写入,那这数据库写速度再快也快不到哪去啊,怎么实现网站类大并发啊,同一时刻来1000个请求,那不是要10秒才能处理完