New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query Execution Time increases when increasing pool size #1354
Comments
This is likely a problem with threads. Your code (thanks for making it runnable!) shows a per-execution time increase if I increase the pool size but haven't bumped up UV_THREADPOOL_SIZE. Times are stable if I do increase UV_THREADPOOL_SIZE. Give details about how you are setting UV_THREADPOOL_SIZE, and where. Remember on Windows it needs to be set in the environment before Node.js runs. You wouldn't want to make a pool too big - there will always be overheads of accessing a shared resource, not to mention DB limitiations. Check the doc Connection Pool Sizing. And can you answer the issue template questions? Thanks. My results for
|
@cjbj Thanks for quick reply. I am running this on kubernetes using base image of oraclelinux. I am setting UV_THREADPOOL_SIZE from environment variables.
|
@cjbj |
Prove it :) |
@cjbj HAHA. I have logging process.env.UV_THREADPOOL_SIZE in the test function. |
@cjbj ?? |
The way to prove the thread pool sizing was set OK is to run something like pstack on the running process. The number of threads should be your desired number + some more. You could also see if there is different between using 4 & 5 connections, since the default number of worker threads is 4. Check there isn't some system resource restriction that I don't know about. For maximum throughput, your test(500) parameter will need to be (should be) no more than the number of connections in the pool, which should be no more than the number of worker threads. A more natural way to test would be to take examples/webapp.js and throw some parallel load with 'ab' or 'siege' or similar at it. This can be clearer to work with than worrying about what is and isn't async in a single test script. |
Does this mean, if i have an express app and connection pool of 10, i will be able to handle 10 requests in my express app? Actually we have an express app and tested it using jmeter when i observed this behaviour of increasing response time as connections in use increases. I prepared this code for simplification. |
If you have a connection pool with poolMax=10, then only 10 express requests can be doing DB work. The rest can be doing non-DB work, or will be queued up in the node-oracledb pool queue waiting to get a connection. Since setting UV_THREADPOOL_SIZE is the potential issue, you might want to share the code that is setting it. |
NEW CODE
|
Running as
Also output of ps -efL from docker container to ensure worker threads are being created
|
@cjbj Now when i run ab with concurrency of 1
I see
But when i increase concurrent to 10
I get following
Also from app logs i can see response times going beyond 5ms with connections in use reaches 10. But when connection in use is 1 the response times are 0.5ms. |
@cjbj ? |
@SinghBhisham I wonder whether you're seeing the latching overheads of accessing a shared resource (the pool - which you do to get the stats and to get a connection) on a fast machine, where the SQL query cost is tiny? A more practical real-world example would be to compare the |
This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not been updated for a month. |
Node version: 14
Node-oracledb version: 5.1
Oracle DB version: 12.2
When i use pool size of 1 (static pool) all my queries are executed within 1ms. But when i increase the pool size to say 20, same queries start taking more than 5-10ms. I am also increasing UV_THREADPOOL_SIZE when increasing pool size.
Below is a sample code to illustrate my problem
PS: there is an index on crmId.
I am simulating parallel queries here. Basically as the connections in use increases connection.execute start taking more time to complete
The text was updated successfully, but these errors were encountered: