Closed darrenli912 closed 5 years ago
max_connections limits the number of idle connections it will keep around, not the number it will open. If you start additional non blocking queries it will require it to create new connections.
-Dan
On Wed, Aug 29, 2018 at 11:51 PM darrenli912 notifications@github.com wrote:
Steps to reproduce the behavior
- My postgresql db max_connections is 100;
- I set my hypnotoad with 4 works ;
- My Mojolicious pg setting: $self->helper( pg => sub { state $pg = Mojo::Pg->new('postgresql://apple@/devel'); $pg->max_connections(12); } ); From the above settings, the total max connection should be 12*4=48 from mojo::pg.
My 4 non-blocking search in my controller model: my $base_info = $self->pg->db->query_p(...); my $product_content = $self->pg->db->query_p(...); my $photos = $self->pg->db->query_p(...); my $similars = $self->pg->db->query_p(...);
Mojo::Promise->all( $base_info, $product_content, $photos, $similars ) ->then( sub { my ( $base_info, $productcontent, $photos, $similars ) = @;
....... } );
Now I test with ab: ab -n 4000 -c 100 'http://127.0.0.1:3000/url' Expected behavior
The max db connection should be 48. No fail connection. Actual behavior
Get the connection error: FATAL: remaining connection slots are reserved for non-replication superuser connections at /usr/local/share/perl/5.26.1/Mojo/Pg.pm line 91.
The connections are larger than 100 during my ab test. Many test are failed because of failed connections from mojo::pg.
The connection will get back to 48, after the ab test finished.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kraih/mojo-pg/issues/49, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgIjF5Au2z3en4rdgubpamnCMfh0HD5ks5uV2EmgaJpZM4WSuvw .
Got it. Thank you Grinnz.
Steps to reproduce the behavior
My 4 non-blocking search in my controller model: my $base_info = $self->pg->db->query_p(...); my $product_content = $self->pg->db->query_p(...); my $photos = $self->pg->db->query_p(...); my $similars = $self->pg->db->query_p(...);
....... } );
Now I test with ab: ab -n 4000 -c 100 'http://127.0.0.1:3000/url'
Expected behavior
The max db connection should be 48. No fail connection.
Actual behavior
Get the connection error: FATAL: remaining connection slots are reserved for non-replication superuser connections at /usr/local/share/perl/5.26.1/Mojo/Pg.pm line 91.
The connections are larger than 100 during my ab test. Many test are failed because of failed connections from mojo::pg.
The connection will get back to 48, after the ab test finished.