Skip to content
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

how to set properties of connection pool? #69

Closed
gzliudan opened this issue Apr 3, 2018 · 9 comments
Closed

how to set properties of connection pool? #69

gzliudan opened this issue Apr 3, 2018 · 9 comments

Comments

@gzliudan
Copy link

gzliudan commented Apr 3, 2018

such as pool's size, min and max value, keepalive time, etc.

@leafo
Copy link
Owner

leafo commented Apr 4, 2018

You can pass the same parameters you pass to the ngx keepalive method to the pg object's keepalive method

https://github.com/leafo/pgmoon#success-err--postgreskeepalive

@gzliudan
Copy link
Author

gzliudan commented Apr 5, 2018

But I didn't find parameters in the source code of pgmoon/init.moon and pgmoon/socket.lua.
By the way, would you please upload pgmoon to http://opm.openresty.org/ ? So I can use opm command to update pgmoon.

@leafo
Copy link
Owner

leafo commented Apr 5, 2018

@gzliudan the ... is used to pas parameters through to openresty, so their names aren't explicitly listed in this project's source code

I updated the package on opm

@gzliudan
Copy link
Author

gzliudan commented Apr 5, 2018

thanks a lot. I updated pgmoon through opm command.

Can you give an example how to set parameters of connection pool?

@leafo
Copy link
Owner

leafo commented Apr 5, 2018

-- when you want to return the connection to the pool:
pg:keepalive(timeout, pool_size)

-- if you need to configure the pool name:
pgmoon.new({
  pool = "custom pool name",  
  -- ...
})

Generally you don't need to configure the pool name since it will choose a reasonable default based on connection settings.

@gzliudan
Copy link
Author

gzliudan commented Apr 5, 2018

Thank you very much.
Does the unit of timeout is second? What happenes if pool_size is different value when call pg:keepalive with last time.

@leafo
Copy link
Owner

leafo commented Apr 5, 2018

@gzliudan
Copy link
Author

gzliudan commented Apr 5, 2018

Thank you again. Maybe it's better update ReadMe.

@gzliudan gzliudan closed this as completed Apr 5, 2018
@devvit
Copy link

devvit commented Apr 10, 2018

52 closed, continue here.

There are similar issues: 47, 64

How to limit connections in openresty? The answer is here

Basically, we cannot strictly limit connections, in practice, lua_socket_pool_size or #tcpsocksetkeepalive is both overflow-able, that's why cosocket has huge concurrency.

openresty group has more details, for example this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants