当前系统是一台服务器,服务器里面有WEB程序和Mysql数据库,还有一个爬虫。在爬虫未启动时Mysql基本能满足普通的读写功能,一但启动了爬虫,将大量写入数据,服务器的I/O占用情况达到85%-95%左右。大大的影响了Mysql的查询性能。   现将Mysql和Web服务器还有爬虫分开。A,B服务器分别为Mysql的Master和Slave端,使用Mysql-Proxy进行读写分离,Slave端同步Master的数据。爬虫在C服务器上,在启动时将数据直接写入Master端,然后同步至Slave端。   这样子分开后,启动爬虫时Slave端还是不乐观,也影响了Slave的查询效率。   爬虫是二个小时启动一次,它只写入Master的两个表的数据。   请教一下大家怎么处理这样的情况?

解决方案 »

  1.   

    有个工具可以考虑,maatkit中的mk-slave-delay
    cu上也看到了,嘿嘿
      

  2.   

    这样吧。你用计划任务比如linux下的CRONTAB来定时开启SLAVE吧。这样就能起到效果!
      

  3.   

    好像关键在你的同步机制上,另外,还有就是同步的表的索引。
    索引越多,查询的速度越快,但是新增和更新时就会慢,平衡点取决于具体的数据和相应业务。
    同步的时候会锁表/数据,争抢cpu等资源,肯定会影响查询效率。
      

  4.   

    The document said.
    MASTER_POS_WAIT(log_name,log_pos[,timeout]) This function is useful for control of master/slave synchronization. It blocks until the slave has read and applied all updates up to the specified position in the master log. The return value is the number of log events the slave had to wait for to advance to the specified position. The function returns NULL if the slave SQL thread is not started, the slave's master information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if the timeout has been exceeded. If the slave SQL thread stops while MASTER_POS_WAIT() is waiting, the function returns NULL. If the slave is past the specified position, the function returns immediately. If a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeout must be greater than 0; a zero or negative timeout means no timeout.