-
Notifications
You must be signed in to change notification settings - Fork 35
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
Connection pooling in Cluster mode #124
Comments
Hi,
Setting a maximum amount of concurrent connections is not supported by OpenResty as of today. Connection pooling is for idle connections only. Connection queuing will be supported in the next OpenResty release. As of today, you can use a request-aware LB policy (
The cluster module supports auto-preparation of queries by simply specifying the E.g. local options = { prepared = true }
cluster:execute("SELECT * FROM my_table", args, options) |
Thanks for your quick response. I made suggested changes but I still see so many socket timeouts. I am running performance tests and seeing that for almost each request driver is creating a connection to DB server. |
I cannot help you without seeing some code. Most likely, you are doing something wrong. OpenResty programming is tricky. Are you correctly closing opened connections? Or keeping them alive? Are you properly reusing the same connection across a given request? How many connections are opened against your nodes also depends on the traffic pattern. If the number of connections that you are opening is higher than the size of your idle connection pool, you have high chances of opening a new connection for each query. But again, it is more likely because you are misusing this driver - OpenResty programming can be quite tricky. |
@thibaultcha Any update about :
Thanks |
@MaximeFrancoeur Sure, connection queuing is available since OpenResty 1.15.8.1. See the new |
@thibaultcha Do you have documentation about this for lua-cassandra? |
@MaximeFrancoeur Connection pools are already maintained as per the default behaviour documented in the ngx_http_lua module's README. If you want more control over the connection pools, PRs are welcome. |
@thibaultcha just to be sure. When we create a Cassandra Cluster it will create a pool with zero connection. When we will receive first request it will create a connection with 60 seconds timeout idle. This is right? |
@MaximeFrancoeur Pools are created by calling ngx_lua's tcpsock:setkeepalive. As of today, this driver does not support customization of the connection pool (hence my comment for a PR above), but default pools are still in effect. Finally, note that connection pools can also be customized (albeit globally) via the |
A note on my previous comment in this thread:
It is now supported as of OpenResty 1.15.8.1 (as I mention in my above comment). See the |
Hello,
I have two question related to lua-cassandra driver specifically in Cluster mode:
Thanks.
The text was updated successfully, but these errors were encountered: