# Master Slave Replication Issue - Seconds behind master

**URL:** https://forums.percona.com/t/master-slave-replication-issue-seconds-behind-master/4346
**Category:** Other MySQL® Questions
**Created:** [August 13, 2015, 2:34am UTC](https://forums.percona.com/t/master-slave-replication-issue-seconds-behind-master/4346 "2015-08-13T02:34:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![atluri](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@atluri](https://forums.percona.com/u/atluri)
#### Post date: [August 13, 2015, 2:34am UTC](https://forums.percona.com/t/master-slave-replication-issue-seconds-behind-master/4346/1 "2015-08-13T02:34:59Z")

</div>

We have Master Slave Mysql Setup, Master & slave hardware configuration is same (8 Core,30 GB Memory). These servers are Hosted on AWS.

My slave frequently is getting behind master . The current value for Seconds\_Behind\_Master is 114701, Not sure on how to get this sync master & slave Immediately. I can see that .

Master status - mysql-bin.000262 | 514064392  
Slave Status - mysql-bin.000258 | 285395655

Below is my my.cnf configuration from Mysql Slave.

[mysql]

# CLIENT

port = 3306  
socket = /var/lib/mysql/mysql.sock

[mysqld]

# GENERAL

user = mysql  
default-storage-engine = InnoDB  
socket = /var/lib/mysql/mysql.sock  
pid-file = /srv/mysql/mysql.pid  
skip\_name\_resolve

# MyISAM

key-buffer-size = 32M  
myisam-recover = FORCE,BACKUP

# SAFETY

max-allowed-packet = 16M  
max-connect-errors = 1000000

# DATA STORAGE

datadir = /srv/mysql/

# BINARY LOGGING

log-bin = /srv/mysqllogs/mysql-bin  
max\_binlog\_size = 512M  
expire-logs-days = 4  
sync-binlog = 1

# REPLICATION

server-id = 2  
read-only = 1  
log-slave-updates = 1  
relay-log = /srv/mysqllogs/relay-bin  
slave-net-timeout = 60  
sync-master-info = 1  
sync-relay-log = 1  
sync-relay-log-info = 1  
slave-skip-errors = 1062

# CACHES AND LIMITS

tmp-table-size = 128M  
max-heap-table-size = 128M  
query-cache-type = 1  
query-cache-size = 512M  
max-connections = 4096  
thread-cache-size = 100  
open-files-limit = 65535  
table-definition-cache = 4096  
table-open-cache = 10240  
#slave\_parallel\_workers = 3

# INNODB

innodb-flush-method = O\_DIRECT  
innodb-log-files-in-group = 2  
innodb-log-file-size = 256M  
innodb-flush-log-at-trx-commit = 0  
innodb-file-per-table = 1  
innodb-buffer-pool-size = 24G

# LOGGING

log-error = /srv/mysqllogs/mysql-error.log  
#general\_log\_file = /srv/mysqllogs/mysql.log  
#general\_log = 1  
log\_warnings = 2  
#log-queries-not-using-indexes = 1  
#slow-query-log = 1  
#slow-query-log-file = /srv/mysqllogs/mysql-slow.log

#tmpdir = /media/ephemeral0/tmp/

Could some one please help me in identifying & resolving the issue.

---

<div class="post-metadata">

### Author: ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)
#### Post date: [August 13, 2015, 11:07am UTC](https://forums.percona.com/t/master-slave-replication-issue-seconds-behind-master/4346/2 "2015-08-13T11:07:33Z")

</div>

Hi atluri;

From your description, it sounds like the slave is getting behind due to MySQL replication being single-threaded. Your master is likely running large UPDATE/DELETE statements or DML that is taking a while to go through replication and blocking everything else behind it. So I would identify this type of traffic on your master, and the most likely fix will be to split up the UPDATE/DELETE statements into smaller chunks if that is the issue. If it is DML, then the only real work around would be using something like pt-online-schema-change or to run the DML first on your slave and then on the master with binary logging disabled for the session (note that would only work for non-destructive changes, like adding columns though).

-Scott
