Revenue Source

Welcome to the Revenue Source affiliate marketing forums.

You are viewing our internet marketing and SEO forums as a guest which gives you limited access to most of our discussions.  By joining our free community, you will have access to post affiliate marketing topics, communicate privately with other members (PM), exchange SEO strategies, and access many other special features.  Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems, please don't hesitate to contact us.

Go Back   Revenue Source > Site Design & Development > Databases
Reload this Page Figuring out what limits MySQL Replication
Tags: , , ,

Reply
 
LinkBack Thread Tools Search this Thread
Old
  (#1 (permalink))
Affiliate Blogs is Offline
Revenue Source Veteran
Affiliate Blogs has a brilliant future here!
 
Affiliate Blogs's Avatar
 
Join Date: Oct 2005
Posts: 8,626
Jack of All Trades
CyberSpace United States
   
Figuring out what limits MySQL Replication - 03-07-2007

Today I was cloning the master using LVM Snapshot and found it was taking quite a while to catch up, which highlighted replication could be the limiting factor for this system quite soon, so I decided to check what is limiting MySQL Replication speed.
My first idea was to check it based on slow query log, happily the server was running MySQL with slow query log with microsecond resolution so I could check exactly which update queries take most time to execute. Unfortunately it did not work because Slave thread seems to have problems picking up long_query_time when it is set online, meaning changing it via
set global long_query_time=0 and restarting slave does not pick up the change.
I of course could just restart MySQL but this would make replication to be delayed few more hours because of the time Innodb takes to open tables first time after start.
I knew in my case most of the queries are rather simple being updates by primary key or other keys so knowing count was enough for me so I turned my attention to mysqlsla which I remembered parses all kinds of MySQL Logs. Too bad MySQL Binary log is the only one which it does not support natively. Happily it supports "raw" query log file which is basically queries one query per line.
mysqlbinlog almost provides what we're looking for, if you strip out comments, USE statements and SET statements, which was done by running: mysqlbinlog host-relay.000005 | grep -v -i -P "^(SET|use|#)" > q1.log I'm not sure if this would clear everything but in my case it did exactly what was needed.
Now running mysqlsla to get most common queries: ./mysqlsla-1.4 --top 100 --raw q1.log > report.txt
We get report something like:
PLAIN TEXT
SQL:
  1. [FONT='Courier New', Courier, monospace]Reading raw log 'q1.log'[/font]
  2. [FONT='Courier New', Courier, monospace]4032446 total queries, 72740 UNIQUE[/font]
  3. [FONT='Courier New', Courier, monospace]Sorting BY 'c'[/font]
  4. [FONT='Courier New', Courier, monospace] [/font]
  5. [FONT='Courier New', Courier, monospace]__ 001 __________________________________________________ _____________________[/font]
  6. [FONT='Courier New', Courier, monospace] [/font]
  7. [FONT='Courier New', Courier, monospace]Count : 114329 (2%)[/font]
  8. [FONT='Courier New', Courier, monospace] [/font]
  9. [FONT='Courier New', Courier, monospace]UPDATE mlp_rating.rating_day SET filesize=filesize+N, imagesize=imagesize+N, chunk='S' WHERE userid=N AND hitdate='S'[/font]
  10. [FONT='Courier New', Courier, monospace];[/font]
  11. [FONT='Courier New', Courier, monospace] [/font]
  12. [FONT='Courier New', Courier, monospace]__ 002 __________________________________________________ _____________________[/font]
  13. [FONT='Courier New', Courier, monospace] [/font]
  14. [FONT='Courier New', Courier, monospace]Count : 113904 (2%)[/font]
  15. [FONT='Courier New', Courier, monospace] [/font]
  16. [FONT='Courier New', Courier, monospace]UPDATE mlp_user.user SET filedownload=N,imagedownload=N WHERE id=N;[/font]
  17. [FONT='Courier New', Courier, monospace] [/font]
  18. [FONT='Courier New', Courier, monospace]__ 003 __________________________________________________ _____________________[/font]
  19. [FONT='Courier New', Courier, monospace] [/font]
  20. [FONT='Courier New', Courier, monospace]Count : 113731 (2%)[/font]
  21. [FONT='Courier New', Courier, monospace] [/font]
  22. [FONT='Courier New', Courier, monospace]UPDATE mlp_online.user_chat_online SET lastactiondate= 'S',cnt=N WHERE userid=N; [/font]



Which is good to start reviewing queries and finding if they can be merged or optimized any other way.
Still looking at queries which took took the most time to execute would be better but this would need to wait for the next time.


Figuring out what limits MySQL Replication - Read More...
  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Figuring out what limits MySQL Replication
Thread Thread Starter Forum Replies Last Post
Learning MySQL Affiliate Blogs Programming Help 0 02-23-2007 02:18 PM
Getting use of Slave in MySQL Replication Affiliate Blogs Databases 0 02-14-2007 12:06 PM
Making MySQL Replication Parallel Affiliate Blogs Databases 0 01-30-2007 11:19 AM
Learning MySQL Affiliate Blogs Programming Help 0 12-12-2006 02:35 PM
PHP with MySQL Affiliate Blogs Programming Help 0 11-30-2006 01:42 PM



© 2004-6 RevenueSource.com.  All rights reserved.  Do not duplicate or redistribute in any form.
This website and its logos/design are property of RevenueSource.com.  All rights reserved. vBSEO 3.2.0 RC7


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34