too long execution time for pool.getConnection
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.
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.
Otherwise, if you can dig into where the time is being spent and me let know/make a PR, it would be much appreciated.
@dnfrolov what tool you use to load test?
@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
@sidorares I used apache jmeter
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
Interesting. I tried today but was unable to reproduce -latency is linearly proportional to number of connections. Tried with wrk, jmeter and ab
Can you please provide code sample and more testing details?
I used your node-mysql benchmark @dnfrolov
Found the issue, I used express + jade. it was the bottleneck. Thank you for your participation.