title: How to increase the connection throughput for pgbouncer?
body: <p>I am using pgbouncer in transaction mode &amp; trying to allow close to 500 active transaction.
  The purpose is simply to stress test the setup</p>
  
  <p>Current setup:
  [ 'n' clients --->1 pgbouncer ----> 1 postgres ]</p>
  
  <p>I notice that my transaction/second (tps) decreases considerably when I use pgbouncer instead of a direct connection to postgres.</p>
  
  <p>For the same set to transaction (via pgbench)</p>
  
  <ul>
  <li><p>Direct connections   => 10k (tps) appx</p></li>
  <li><p>pgbouncer connection => 3k (tps) appx</p></li>
  </ul>
  
  <p>Is there any configuration in pgbouncer that needs to be tuned to allow a better performance?</p>
  
  <p>I understand pgbouncer is a single threaded application, but would like to tune it till its best.
  Following is my pgbouncer configuration:</p>
  
  <p><em>pgbouncer.ini</em></p>
  
  <pre><code>pool_mode = transaction
  server_reset_query =
  
  # Time outs
  server_lifetime=6000
  server_idle_timeout=0
  server_connect_timeout=30
  
  
  #pool configuration
  max_client_conn=10000
  default_pool_size=500
  pool_size=500
  
  ##other
  pkt_buf=4096
  server_login_retry=2
  </code></pre>
  
  <p>The only application I can see is to use multiple pgbouncers to point to the same db server.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>while executing the test:</p>
  
  <p>cpu utilization : 30% appx</p>
  
  <p>disk utilization : 40% appx</p>
  
  <p>Observation: many transactions in 'idle' state</p>
  
  <p><strong>TEST DETAILS:</strong></p>
  
  <p>10 machine acting as clients running pgbench firing request to the DB server.</p>
  
  <p>command:  pgbench -h  -p 6541 -c 512 -j 16 -f pgbench_SchemaScript.sql -T 360 -U postgres test</p>
  
  <p><em>pgbench_SchemaScript.sql</em></p>
  
  <pre><code>\setrandom delta 0 100000
  insert into t1.emplog values(nextval('t1.employeeSeq'),:delta);
  </code></pre>
  
  <p>1 DB server with pgbouncer installed (16core , 24 Gb RAM)</p>