<div style="font:14px/1.5 'Lucida Grande', '微软雅黑';color:#333;"><p style="font:14px/1.5 'Lucida Grande';margin:0;">Thanks for reply.&nbsp;</p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><br></p><p style="font:14px/1.5 'Lucida Grande';margin:0;">I have change test command to :</p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><br></p><p style="font:14px/1.5 'Lucida Grande';margin:0;">&nbsp;<span style="white-space: pre-wrap; font-family: 'Lucida Grande', 微软雅黑; line-height: 1.5;">pgbench -l -C -c $CLIENTS -T $TIME -r pgbench -p9999 -h192.168.9.190 -Unopass</span></p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><span style="white-space: pre-wrap; font-family: 'Lucida Grande', 微软雅黑; line-height: 1.5;"><br></span></p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><span style="white-space: pre-wrap; font-family: 'Lucida Grande', 微软雅黑; line-height: 1.5;">But the test result is as before :  Pgpool bench test tps is too low than direct test postgresql.</span></p><div><br></div><div><br></div>I guess the reason is that:<div><br></div><div>&nbsp;With pgpool , the active database connection is very low (avg &lt;10,&nbsp;<span style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif; widows: 1; color: rgb(34, 34, 34); font-size: 15px; line-height: 19px;">Concurrent clients connections &gt; 512</span><span style="line-height: 1.5;">).</span></div><div>&nbsp;Direct bench test with Postgresql , the active database connection is very high (avg &gt; 60,&nbsp;<span style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif; widows: 1; color: rgb(34, 34, 34); font-size: 15px; line-height: 19px;">Concurrent clients connections &gt; 512</span><span style="line-height: 1.5;">). &nbsp;</span></div><div><div><div style="font: 14px/1.5 'Lucida Grande';"><div class="sign" style="color: rgb(51, 51, 51); widows: 1; padding: 20px 10px; line-height: 22px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif !important;"><br></div><div class="sign" style="color: rgb(51, 51, 51); widows: 1; padding: 20px 10px; line-height: 22px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif !important;"><br><div class="contact" style="border-bottom-color: rgb(229, 229, 229); padding: 15px 0px; margin-top: 18px; border-top-color: rgb(229, 229, 229); border-top-width: 1px; border-top-style: solid;"><p style="margin-top: 0px; margin-bottom: 10px; line-height: 18px; color: rgb(118, 116, 116); font-size: 12px;">地址:广州市珠江新城花城大道18号建滔广场2101室 (邮编:510000)</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: 18px; color: rgb(118, 116, 116); font-size: 12px;">Phone:+86 137 5171 0549</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: 18px; color: rgb(118, 116, 116); font-size: 12px;">Email:<a href="mailto:liujf3@ucweb.com" target="_blank" title="mailto:liujf3@ucweb.com" style="color: rgb(19, 109, 186); text-decoration: none; -webkit-user-drag: none;">liujinfei@xiangrikui.com</a></p><p style="margin-top: 0px; margin-bottom: 0px; line-height: 18px; color: rgb(118, 116, 116); font-size: 12px;">Skype : scofier.liu</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: 18px; color: rgb(118, 116, 116); font-size: 12px;"><br></p></div></div></div></div><span style="font: 14px/1.5 'Lucida Grande';color:#333;"><br></span><div class="foxmail_blockquote_fromhere_element" style="font: 12px/1.5 'Lucida Grande';padding:2px 0 2px 0;"><span style="color:#333;text-decoration:line-through;white-space:pre-wrap;">                            </span>&nbsp;原始邮件&nbsp;<span style="color:#333;text-decoration:line-through;white-space:pre-wrap;">                            </span></div><div style="font: 12px/1.5 'Lucida Grande';background:#efefef;color:#666666;padding:8px;"><div><b style="color:#999;">发件人:</b>&nbsp;Tatsuo Ishii&lt;ishii@postgresql.org&gt;</div><div><b style="color:#999;">收件人:</b>&nbsp;liujinfei&lt;liujinfei@xiangrikui.com&gt;</div><div><b style="color:#999;">抄送:</b>&nbsp;pgpool-general&lt;pgpool-general@pgpool.net&gt;</div><div><b style="color:#999;">发送时间:</b>&nbsp;2015年8月11日(周二) 11:28</div><div><b style="color:#999;">主题:</b>&nbsp;Re: [pgpool-general: 3942] Re: pgpool establish new connectiontooslow</div></div><br><div class="mail_quote_94D7A607C02B42FAA52640E74EA0A21E" style="font: 14px/1.5 'Lucida Grande';color:#333;"><pre style="white-space:pre-wrap;">I forgot an important point: I recommend to add "-C" option to pgbench
if you want to test more real world type load.  Web applications
frequetly connect/disconnect to database. -C simulates this (in this
case you should look into TPS with "including connections
establishing").

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: <a href="http://www.sraoss.co.jp/index_en.php" title="http://www.sraoss.co.jp/index_en.php">http://www.sraoss.co.jp/index_en.php</a>
Japanese:<a href="http://www.sraoss.co.jp" title="http://www.sraoss.co.jp">http://www.sraoss.co.jp</a>

&gt; Hi,Tatsuo Ishii
&gt; The test server has enough resource (cpu,mem,io) to handle the test. (6vCPU, 32GB Mem, 200GB sata)
&gt; I have postgresql and pgpool deployed as follow:
&gt;  pgpool : 192.168.9.132 (master), 192.168.9.133(slaver)  postgresql: 192.168.9.132 (slaver), 192.168.9.133(master)
&gt; The server load both 132 and 133 is very low ( 1 ) when test with pgpool. (Concurrent connections  512)
&gt; My test command ( execute on server 192.168.9.203) :
&gt; pgbench -l -c $CLIENTS -T $TIME -r pgbench -p9999 -h192.168.9.190 -Unopass
&gt; pgbench -l -c $CLIENTS -T $TIME -r pgbench -p5432 -h192.168.9.203 -Unopass
&gt; 
&gt; 
&gt; The test result is :
&gt; pgp: is represent for pgbench with pgpool
&gt; pg: is represent for pgbench with postgresql
&gt; 
&gt; 
&gt; My Configuration and Env is :
&gt; [postgres@dbk pgp]$ cat /proc/sys/kernel/sem
&gt; 250 32000 32 128
&gt; postgres.conf
&gt; max_connections = 2500
&gt; pgpool.conf
&gt; listen_addresses = '*'
&gt; port = 9999
&gt; socket_dir = '/tmp'
&gt; listen_backlog_multiplier = 2
&gt; pcp_listen_addresses = '*'
&gt; pcp_port = 9898
&gt; pcp_socket_dir = '/tmp'
&gt; backend_hostname0 = 'pgtest1.xrktest.com'
&gt; backend_port0 = 5432
&gt; backend_weight0 = 1
&gt; backend_data_directory0 = '/data/pgdata'
&gt; backend_flag0 = 'ALLOW_TO_FAILOVER'
&gt; backend_hostname1 = 'pgtest2.xrktest.com'
&gt; backend_port1 = 5432
&gt; backend_weight1 = 1
&gt; backend_data_directory1 = '/data/pgdata'
&gt; backend_flag1 = 'ALLOW_TO_FAILOVER'
&gt; enable_pool_hba = on
&gt; pool_passwd = 'pool_passwd'
&gt; authentication_timeout = 60
&gt; ssl = off
&gt; num_init_children = 1012
&gt; max_pool = 4
&gt; child_life_time = 300
&gt; child_max_connections = 0
&gt; connection_life_time = 0
&gt; client_idle_limit = 0
&gt; log_destination = 'stderr'
&gt; log_line_prefix = '%t: pid %p: '  # printf-style string to output at beginning of each log line.
&gt; log_connections = on
&gt; log_hostname = on
&gt; log_statement = on
&gt; log_per_node_statement = off
&gt; log_standby_delay = 'none'
&gt; syslog_facility = 'LOCAL0'
&gt; syslog_ident = 'pgpool'
&gt; debug_level = 0
&gt; pid_file_name = '/home/postgres/local/pgpool/var/pgpool.pid'
&gt; logdir = '/home/postgres/local/pgpool/var/pgpool'
&gt; connection_cache = on
&gt; reset_query_list = 'ABORT; DISCARD ALL'
&gt; replication_mode = off
&gt; replicate_select = off
&gt; insert_lock = on
&gt; lobj_lock_table = ''
&gt; replication_stop_on_mismatch = off
&gt; failover_if_affected_tuples_mismatch = off
&gt; load_balance_mode = on
&gt; ignore_leading_white_space = on
&gt; white_function_list = ''
&gt; black_function_list = 'nextval,setval,nextval,setval'
&gt; database_redirect_preference_list = ''
&gt; app_name_redirect_preference_list = ''
&gt; allow_sql_comments = off
&gt; master_slave_mode = on
&gt; master_slave_sub_mode = 'stream'
&gt; sr_check_period = 0
&gt; sr_check_user = 'repuser'
&gt; sr_check_password = 'rep123'
&gt; delay_threshold = 0
&gt; follow_master_command = ''
&gt; health_check_period = 0
&gt; health_check_timeout = 20
&gt; health_check_user = 'repuser'
&gt; health_check_password = 'rep123'
&gt; health_check_max_retries = 0
&gt; health_check_retry_delay = 1
&gt; connect_timeout = 10000
&gt; failover_command = ''
&gt; failback_command = ''
&gt; fail_over_on_backend_error = on
&gt; search_primary_node_timeout = 10
&gt; recovery_user = 'repuser'
&gt; recovery_password = 'rep123'
&gt; recovery_1st_stage_command = ''
&gt; recovery_2nd_stage_command = ''
&gt; recovery_timeout = 90
&gt; client_idle_limit_in_recovery = 0
&gt; use_watchdog = on
&gt; trusted_servers = ''
&gt; ping_path = '/bin'
&gt; wd_hostname = 'pgtest1.xrktest.com'
&gt; wd_port = 9000
&gt; wd_authkey = ''
&gt; delegate_IP = '192.168.9.190'
&gt; ifconfig_path = '/sbin'
&gt; if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0'
&gt; if_down_cmd = 'ifconfig eth0:0 down'
&gt; arping_path = '/usr/sbin'      # arping command path
&gt; arping_cmd = 'arping -U $_IP_$ -w 1'
&gt; clear_memqcache_on_escalation = on
&gt; wd_escalation_command = ''
&gt; wd_lifecheck_method = 'heartbeat'
&gt; wd_interval = 10
&gt; wd_heartbeat_port = 9694
&gt; wd_heartbeat_keepalive = 2
&gt; wd_heartbeat_deadtime = 30
&gt; heartbeat_destination0 = 'pgtest2.xrktest.com'
&gt; heartbeat_destination_port0 = 9694
&gt; heartbeat_device0 = ''
&gt; wd_life_point = 3
&gt; wd_lifecheck_query = 'SELECT 1'
&gt; wd_lifecheck_dbname = 'template1'
&gt; wd_lifecheck_user = 'nobody'
&gt; wd_lifecheck_password = ''
&gt; other_pgpool_hostname1 = 'pgtest2.xrktest.com'
&gt; other_pgpool_port1 = 5432
&gt; other_wd_port1 = 9000
&gt; relcache_expire = 0
&gt; relcache_size = 256
&gt; check_temp_table = on
&gt; check_unlogged_table = on
&gt; memory_cache_enabled = off
&gt; memqcache_method = 'shmem'
&gt; memqcache_memcached_host = 'localhost'
&gt; memqcache_memcached_port = 11211
&gt; memqcache_total_size = 67108864
&gt; memqcache_max_num_cache = 1000000
&gt; memqcache_expire = 0
&gt; memqcache_auto_cache_invalidation = on
&gt; memqcache_maxcache = 409600
&gt; memqcache_cache_block_size = 1048576
&gt; memqcache_oiddir = '/var/log/pgpool/oiddir'
&gt; white_memqcache_table_list = ''
&gt; black_memqcache_table_list = ''
&gt; 
&gt; 
&gt; I realy don’t know where am i wrong.
&gt; The test result is very bad. (Lost 70% of the tps)
&gt; 
&gt; 
&gt; Is there something I can do to improve it?
&gt; 
&gt; 
&gt; Phone:+86 137 5171 0549
&gt; Email:<a href="mailto:liujinfei@xiangrikui.com" title="mailto:liujinfei@xiangrikui.com">liujinfei@xiangrikui.com</a>
&gt; Skype : scofier.liu
&gt; 原始邮件
&gt; 发件人:Tatsuo <a href="mailto:Ishiiishii@postgresql.org" title="mailto:Ishiiishii@postgresql.org">Ishiiishii@postgresql.org</a>
&gt; 收件人:<a href="mailto:liujinfeiliujinfei@xiangrikui.com" title="mailto:liujinfeiliujinfei@xiangrikui.com">liujinfeiliujinfei@xiangrikui.com</a>
&gt; 抄送:<a href="mailto:pgpool-generalpgpool-general@pgpool.net" title="mailto:pgpool-generalpgpool-general@pgpool.net">pgpool-generalpgpool-general@pgpool.net</a>
&gt; 发送时间:2015年8月10日(周一) 13:46
&gt; 主题:Re: [pgpool-general: 3942] Re: pgpool establish new connection tooslow
&gt; 
&gt; 
&gt;  pgpool : 192.168.9.132 (master), 192.168.9.133(slaver)  postgresql: 192.168.9.132 (slaver), 192.168.9.133(master)  pgbench 192.168.9.203      When i test with postgresql, it cost a little time ( 5 seconds) to establish new connection.   I assume you run pgbench on 192.168.9.203.   So one PostgreSQL server spends 5 seconds for opening 1024  connections. Because you have two PostgreSQL servers spending 10  seconds to open 1024 connections to both PostgreSQL. But still extra  10 seconds does not explain. Let me think it about... One possible explanation is, 192.168.9.132 does not have enough CPU/memory resource to handle 2048 process (1024 pgpool-II + 1024 PostgreSQL). For example 2048 process will produce significant context switches which in turn gives high CPU load. Can you add more resource to the server? Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: <a href="http://www.sraoss.co.jp/index_en.php" title="http://www.sraoss.co.jp/index_en.php">http://www.sraoss.co.jp/index_en.php</a> Japanese:<a href="http://www.sraoss.co.jp" title="http://www.sraoss.co.jp">http://www.sraoss.co.jp</a>
</pre></div></div></div>