ソースを参照

Merge pull request #1407 from Eyepea/increase_pgsql_connections

Increase pgsql connections
Mike Smith 10 年 前
コミット
9eee16199f
2 ファイル変更25 行追加3 行削除
  1. 16 3
      config/postgresql.conf
  2. 9 0
      toolset/benchmark/benchmarker.py

+ 16 - 3
config/postgresql.conf

@@ -61,7 +61,7 @@ listen_addresses = '*'		# what IP address(es) to listen on;
 					# defaults to 'localhost', '*' = all
 					# defaults to 'localhost', '*' = all
 					# (change requires restart)
 					# (change requires restart)
 port = 5432				# (change requires restart)
 port = 5432				# (change requires restart)
-max_connections = 2000			# (change requires restart)
+max_connections = 5000			# (change requires restart)
 # Note:  Increasing max_connections costs ~400 bytes of shared memory per
 # Note:  Increasing max_connections costs ~400 bytes of shared memory per
 # connection slot, plus lock space (see max_locks_per_transaction).
 # connection slot, plus lock space (see max_locks_per_transaction).
 #superuser_reserved_connections = 3	# (change requires restart)
 #superuser_reserved_connections = 3	# (change requires restart)
@@ -105,8 +105,21 @@ ssl = false                             # (change requires restart)
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 
 
 # - Memory -
 # - Memory -
-
-shared_buffers = 32MB			# min 128kB
+# values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench
+# details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-query.html
+shared_buffers = 2GB                    # min 128kB
+work_mem = 64MB                                # min 64kB
+maintenance_work_mem = 512MB            # min 1MB
+checkpoint_segments = 64
+checkpoint_completion_target = 0.9
+effective_cache_size = 8GB
+
+# when executed on the SSD (otherwise 4)
+random_page_cost = 2
+
+#shared_buffers = 32MB			# min 128kB
 					# (change requires restart)
 					# (change requires restart)
 #temp_buffers = 8MB			# min 800kB
 #temp_buffers = 8MB			# min 800kB
 #max_prepared_transactions = 0		# zero disables the feature
 #max_prepared_transactions = 0		# zero disables the feature

+ 9 - 0
toolset/benchmark/benchmarker.py

@@ -376,12 +376,21 @@ class Benchmarker:
     p.communicate("""
     p.communicate("""
       sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
       sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
       sudo sysctl -w net.core.somaxconn=65535
       sudo sysctl -w net.core.somaxconn=65535
+      sudo sysctl -w kernel.sched_autogroup_enabled=0
       sudo -s ulimit -n 65535
       sudo -s ulimit -n 65535
       sudo sysctl net.ipv4.tcp_tw_reuse=1
       sudo sysctl net.ipv4.tcp_tw_reuse=1
       sudo sysctl net.ipv4.tcp_tw_recycle=1
       sudo sysctl net.ipv4.tcp_tw_recycle=1
       sudo sysctl -w kernel.shmmax=2147483648
       sudo sysctl -w kernel.shmmax=2147483648
       sudo sysctl -w kernel.shmall=2097152
       sudo sysctl -w kernel.shmall=2097152
+      sudo sysctl -w kernel.sem="250 32000 256 512"
+      echo "Printing kernel configuration:" && sudo sysctl -a
     """)
     """)
+        # Explanations:
+        # net.ipv4.tcp_max_syn_backlog, net.core.somaxconn, kernel.sched_autogroup_enabled: http://tweaked.io/guide/kernel/
+        # ulimit -n: http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
+        # net.ipv4.tcp_tw_*: http://www.linuxbrigade.com/reduce-time_wait-socket-connections/
+        # kernel.shm*: http://seriousbirder.com/blogs/linux-understanding-shmmax-and-shmall-settings/
+        # For kernel.sem: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/chap-Oracle_9i_and_10g_Tuning_Guide-Setting_Semaphores.html
   ############################################################
   ############################################################
   # End __setup_database
   # End __setup_database
   ############################################################
   ############################################################