Home » Performance » MySQL » major connection spike during "source dumpfile.sql"
major connection spike during "source dumpfile.sql" [message #1547] Mon, 23 July 2007 17:23 Go to next message
RichardBronosky  is currently offline RichardBronosky
Messages: 20
Registered: June 2007
Junior Member
I have a master server (with one slave) that I have noticed this on. When I connect to the master from my workstation via:
mysql -h master

and then try to load a 80MB to 500MB SQL file generated from mysql dump, like so:
source dumpfile.sql

It takes several minutes to load because of the effected indexes. But during that time I see my connection go from in the 20's to in to 250's even 500's at one point. (According to the MySQL Network Monitoring and advisory server tool.)

Has anyone ever seen anything like this?



.+# Richard Bronosky #+.
MySQL DBA, MythTV User
Re: major connection spike during "source dumpfile.sql" [message #1617 is a reply to message #1547 ] Thu, 16 August 2007 11:04 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Well it is the extra load to import the data which can be the reason.

If you're importing the same tables which are being accessed it also may be table locks issue.

Run SHOW PROCESSLIST and see what those connections are doing.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: major connection spike during "source dumpfile.sql" [message #1633 is a reply to message #1547 ] Thu, 16 August 2007 15:10 Go to previous messageGo to next message
RichardBronosky  is currently offline RichardBronosky
Messages: 20
Registered: June 2007
Junior Member
As an enterprise customer, I have been discussing this with MySQL AB also.

Here is what I have come up with:


  1. It turns out that there is no problem with my mysql client.
    1. It is only making one connection.
    2. The server is only creating one thread for the connection.
  2. My server receives about 50 connections per second.
  3. It generally only ever has 20 connections open at one time, because the client gets on, does its select, and leaves so fast.
  4. The duration of these other connections goes way up during the bulk loading process due to Disk I/O, CPU for indexing, and RAM for statement buffering.
  5. The number of concurrent connections maxes out when the duration of each goes from hundredths of a second to multiple seconds each.


This is all very logical. Now I have to decide what to do about it. I'd like to have an app that can take a dump file and break the extended inserts up into a configurable number of records per statement, then execute the statements with a configurable delay in between. Does something like this exist?

I thought about using a proxy to do traffic shaping to limit the rate at which the server receives the SQL statements, but extended inserts won't get broken up using this technique. Hmmm. I wonder how hard it would be to write a SQL insert aware proxy service. That way, even if the data imports are done using MySQL GUI Tools, Navicat, or MS SQL/SSIS via linked tables... It all get throttled if you connect to the proxy instead of directly to the server.

Peter, am I missing something?

BTW, I really enjoyed seeing you at MySQL Conf '07



.+# Richard Bronosky #+.
MySQL DBA, MythTV User
Re: major connection spike during "source dumpfile.sql" [message #1641 is a reply to message #1633 ] Fri, 17 August 2007 06:22 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Are you loading the same tables as those which accessed or completely different ones ?

If it is different set of tables you just need some throttling on servers so it does not take so much resources.

One idea is to load table by table if they are small with sleep in between.

If that does not work you can either patch mysqldump or write little sql-dump post processor which will add MySQL sleep() function between the lines so it can be spread over longer time.

You can change number of inserts in the bulk by max_allowed_packet changing ad you also can set mysqldump to use single row inserts which makes it slower but you can spread it to have very low side load


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: major connection spike during "source dumpfile.sql" [message #1645 is a reply to message #1641 ] Sat, 18 August 2007 01:42 Go to previous message
RichardBronosky  is currently offline RichardBronosky
Messages: 20
Registered: June 2007
Junior Member

  1. Most of the time new ones. But some times existing, currently used ones.
  2. Yes, this would help for most of my needs.
  3. Actually, the tables are very huge. And often the entire problematic load in only one table.
  4. I did not know about sleep(). Thank you for this gem!
  5. I've been looking into max_allowed_packet, I think I will have to use it. I don't like the single inserts because they are not just slower, but are slower due to overhead that is avoided by using extended-inserts.



I think I will patch mysqldump to add an option like --sleep-between-inserts=<duration>



.+# Richard Bronosky #+.
MySQL DBA, MythTV User
Previous Topic:Benchmark needed: WHERE id='$id' ... vs. WHERE id=$id
Next Topic:Difference between Falcon's and InnoDB's row level locking/MVCC
Goto Forum:
  


Current Time: Sat Jul 4 17:45:36 EDT 2009

Total time taken to generate the page: 0.01322 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.