Error: sorry, too many clients already

后端 未结 2 1000
执念已碎
执念已碎 2021-01-15 15:12

I am using PostgreSQL in my NodeJS backend service. All of sudden, when I start the service I am facing below error

 connection error error: sorry, too many         


        
相关标签:
2条回答
  • 2021-01-15 15:31

    I experienced the same issue that " sorry, too many clients already. Request timeout". I managed to solve it. There are some ways which you can try

    1)The first one that you can increase the number of maximum connections and other settings in sequilize like

      { 
        max: 95,    //maximum connection which postgresql or mysql can intiate
        min: 0,     //maximum connection which postgresql or mysql can intiate
        acquire:20000, // time require to reconnect 
        idle: 20000, // get idle connection
        evict:10000 // it actualy removes the idle connection
       }
    

    2). The second way is to use timescaledb because sometimes with complex queries we get timeout error for timescale data you can set timescaledb so you can run complex database queries. you can also set maximum clients for postgres according to your server requirement.

    https://github.com/timescale/timescaledb-tune

    0 讨论(0)
  • 2021-01-15 15:43

    below query will help you.

    select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal 
    from 
      (select count(*) used from pg_stat_activity) t1,
      (select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2,
      (select setting::int max_conn from pg_settings where name=$$max_connections$$) t3
    
    0 讨论(0)
提交回复
热议问题