mysql icon indicating copy to clipboard operation
mysql copied to clipboard

too long execution time for pool.getConnection

Open dnfrolov opened this issue 11 years ago • 10 comments

I've recently faced an issue with high load. After I spent a couple of days making tests I've found out interesting pool.getConnection behavior.

I created simple express app using jade to render results from data base. I used node-mysql to access DB. Then I created jmeter test and made some testing.

Connection Limit: 10, Ramp-up: 1s, Loop Count: 1 Threads (Users): 100, Avg Response: ~4ms. cool Threads (Users): 200, Avg Response: ~14ms. cool Threads (Users): 300, Avg Response: ~250ms. sad

I didn't expect so much increase in Avg Response and after short research I found that most time consuming process is getConnection from pool - approx 90%.

Ok let's increase Connection Limit: 20. But it doesn't help. Threads (Users): 300, Avg Response: ~250ms.

Then I add one more node process using cluster and it helps: Threads (Users): 300, Avg Response: ~25ms.

Can you please suggest me other way of resolving the problem?

You can find samples here https://github.com/dnfrolov/node-performance.

dnfrolov avatar May 15 '15 12:05 dnfrolov

Your connectionLimit is probably too low for your load. Can you raise it above 10? Otherwise you will get high wait times, because that is how pooling works.

dougwilson avatar May 15 '15 13:05 dougwilson

Otherwise, if you can dig into where the time is being spent and me let know/make a PR, it would be much appreciated.

dougwilson avatar May 15 '15 13:05 dougwilson

@dnfrolov what tool you use to load test?

sidorares avatar May 15 '15 13:05 sidorares

@dougwilson I've used 20 connection limit but got the same timings. I've checked it with SQL Profile to be sure that all 10/20 connections were created

dnfrolov avatar May 15 '15 13:05 dnfrolov

@sidorares I used apache jmeter

dnfrolov avatar May 15 '15 13:05 dnfrolov

I have more details:

If there are 200 threads then no one connection is pushed to _connectionQueue. But if there are 300 threads then approx ~270 connections are pushed to _connectionQueue. Time range spent in queue is 4ms - 400ms

dnfrolov avatar May 18 '15 10:05 dnfrolov

Interesting. I tried today but was unable to reproduce -latency is linearly proportional to number of connections. Tried with wrk, jmeter and ab

sidorares avatar May 18 '15 10:05 sidorares

Can you please provide code sample and more testing details?

dnfrolov avatar May 18 '15 10:05 dnfrolov

I used your node-mysql benchmark @dnfrolov

sidorares avatar May 18 '15 10:05 sidorares

Found the issue, I used express + jade. it was the bottleneck. Thank you for your participation.

dnfrolov avatar May 18 '15 11:05 dnfrolov