设为首页 收藏本站
查看: 719|回复: 0

[经验分享] MySQL压测--异步与半同步复制

[复制链接]

尚未签到

发表于 2018-10-5 11:18:12 | 显示全部楼层 |阅读模式
  最近在看MySQL5.7 Manual,有关Semisynchronous Replication这一块的内容,我们知道,MySQL默认的Replication是异步的,何为异步?何为半同步?废话不多说,直接看官方解释吧:
  1.背景知识
  
  Asynchronous replication
  the master writes events to its binary log and slaves request them when they are ready. There is no guarantee that any event will ever reach any slave.
  --主库只管把events写入binlog中,不管从库有没有收到。
  Fully synchronous replication
  when a master commits a transaction, all slaves also will have committed the transaction before the master returns to the session that performed the transaction. The drawback of this is that there might be a lot of delay to complete a transaction.
  --主库提交一个事物,需要等待所有从库先提交才能返回结果,执行这个事物。这样会造成一个事物延时。
  Semisynchronous replication
  falls between asynchronous and fully synchronous replication. The master waits only until at least one slave has received and logged the events. It does not wait for all slaves to acknowledge receipt, and it requires only receipt, not that the events have been fully executed and committed on the slave side.
  --介于异步复制和全复制之间,主库仅仅只要等待至少一个从库收到和记录events。它不需要等待所有的从库告诉它收到events,也不需要从库执行和提交事物,从库只是收到events就会告诉主库,这样主库就可以提前提交事物了。
  此外,半同步也分两种,有参数rpl_semi_sync_master_wait_point控制,这里我就不多做解释了,我们使用默认设置after_sync,这种数据零丢失
  AFTER_SYNC (the default): The master writes each transaction to its binary log and the slave, and syncs the binary log to disk. The master waits for slave acknowledgment of transaction receipt after the sync. Upon receiving acknowledgment, the master commits the transaction to the storage engine and returns a result to the client, which then can proceed.
  AFTER_COMMIT: The master writes each transaction to its binary log and the slave, syncs the binary log, and commits the transaction to the storage engine. The master waits for slave acknowledgment of transaction receipt after the commit. Upon receiving acknowledgment, the master returns a result to the client, which then can proceed.
  
  2.测试环境
RoleHostnameIPCPUMemoryMySQL VersionTPCCsht-sgmhadoopcm-01172.16.101.542Core8GNOmastersht-sgmhadoopdn-01172.16.101.582Core6G5.7.21slave1sht-sgmhadoopdn-02172.16.101.592Core6G5.7.21slave2sht-sgmhadoopdn-03172.16.101.602Core6G5.7.21  一个master,slave1和slave2都是master的直接从库。
  分两种情况测试:
  (1)当slave1和slave2都是异步复制的时候
  (2)当slave1是半同步复制,slave2是异步复制的时候
  
  3.压力测试
  
  使用TPCC压力测试软件,比较TPS判断异步和半同步复制的性能差异到底有多大。
  具体如何测试,可以参考之前的博客:MySQL压测--TPCC安装,测试

  •   通过TPCC测试获得的数据库TpmC数据
Thread CountAsynchronousSemisynchronous41145.9001081.13381966.6331687.933163202.3332538.233324363.5333302.167645112.9003638.6671285257.2673738.1002565199.7333823.8335124753.7003538.63310243268.6332769.66715362294.0002215.733

  •   绘制折线图像
DSC0000.jpg

  4.总结
  
  从本测试结果可以看出:

  •   无论是半同步复制还是异步复制,数据库的TpmC刚开始随着并发线程的增加而增加,到达200个左右,TpmC开始逐渐下降;
  •   当线程数在16-1024左右之间,异步复制的TpmC明显比半同步的大很多,相差大概1000-2000左右,所以半同步相比异步性能是要下降很多;
  •   如果你的数据库并发并不是很多,又对数据安全要求比较高,可以优先考虑使用半同步复制;
  
  参考链接:
  半同步复制安装配置
  https://dev.mysql.com/doc/refman/5.7/en/replication-semisync.html


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-612600-1-1.html 上篇帖子: 搭建MySql主从复制与读写分离 下篇帖子: centos同时运行mysql5.6和mysql5.7
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表