← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-documenters/dhis2/dhis2-docbook-docs] Rev 716: Postgres performance

 

------------------------------------------------------------
revno: 716
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2-docbook-docs
timestamp: Sun 2013-03-24 20:32:08 +0100
message:
  Postgres performance
modified:
  src/docbkx/en/dhis2_implementation_guide_installation.xml


--
lp:~dhis2-documenters/dhis2/dhis2-docbook-docs
https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs

Your team DHIS 2 developers is subscribed to branch lp:~dhis2-documenters/dhis2/dhis2-docbook-docs.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs/+edit-subscription
=== modified file 'src/docbkx/en/dhis2_implementation_guide_installation.xml'
--- src/docbkx/en/dhis2_implementation_guide_installation.xml	2013-03-24 18:40:01 +0000
+++ src/docbkx/en/dhis2_implementation_guide_installation.xml	2013-03-24 19:32:08 +0000
@@ -16,19 +16,26 @@
     <para>For a national server the recommended configuration is a quad-core 2 Ghz processor or
       higher and 12 Gb RAM or higher. Note that a 64 bit operating system is required for utilizing
       more than 4 Gb of RAM, the Ubuntu 12.04 64 bit edition is thus recommended. </para>
-    <para>For this guide we assume that 7 Gb RAM is allocated for PostgreSQL and 7 GB RAM is
+    <para>For this guide we assume that 8 Gb RAM is allocated for PostgreSQL and 8 GB RAM is
       allocated for Tomcat/JVM, and that a 64-bit operating system is used. <emphasis role="italic"
         >If you are running a different configuration please adjust the suggested values
         accordingly!</emphasis> We recommend that the available memory is split roughly equally
       between the database and the JVM. Remember to leave some of the physical memory to the
-      operating system for it to perform its tasks. The steps marked as <emphasis role="italic"
-        >optional</emphasis>, like the step for performance tuning, can be done at a later
-      stage.</para>
+      operating system for it to perform its tasks, for instance around 2 GB. The steps marked as
+        <emphasis role="italic">optional</emphasis>, like the step for performance tuning, can be
+      done at a later stage.</para>
     <para><emphasis role="bold">Create new user (optional)</emphasis></para>
-    <para>You might want to create a dedicated user for running DHIS - it is not recommended to run as the root user. Create a new user called dhis  by invoking <code>useradd -d /home/dhis -m dhis -s /bin/bash</code>     Then make the user able to perform operations temporarily as root user by invoking <code>usermod -G admin dhis</code> If there is no admin group you must create it first by invoking <code>groupadd admin</code> Then invoke <code>passwd dhis</code> to set the password for your account. Make sure you set a strong password with at least 15 random characters. You might want to disable remote login for the root account for improved security by invoking <code>sudo passwd -l root</code></para>
+    <para>You might want to create a dedicated user for running DHIS - it is not recommended to run
+      as the root user. Create a new user called dhis by invoking <code>useradd -d /home/dhis -m
+        dhis -s /bin/bash</code> If there is no admin group already you must create it by invoking
+        <code>groupadd admin</code> Then make the user able to perform operations temporarily as
+      root by invoking <code>usermod -G admin dhis</code> Then invoke <code>passwd dhis</code> to
+      set the password for your account. Make sure you set a strong password with at least 15 random
+      characters. You might want to disable remote login for the root account for improved security
+      by invoking <code>sudo passwd -l root</code></para>
     <para><emphasis role="bold">Operating system kernel tuning</emphasis></para>
     <para>These settings are optional except for the shared memory setting which is required for PostgreSQL memory allocation. Open the kernel configuration file by invoking <code>sudo nano /etc/sysctl.conf</code> At the end of the file add the following lines and save.</para>
-    <screen>kernel.shmmax = 1610612736
+    <screen>kernel.shmmax = 4294967296
 net.core.rmem_max = 8388608
 net.core.wmem_max = 8388608</screen>
     <para>Make the changes take effect by invoking <code>sudo sysctl -p</code></para>
@@ -52,23 +59,26 @@
     <para>Do performance tuning by opening the following  file by invoking </para>
     <para><code>sudo nano /etc/postgresql/9.2/main/postgresql.conf</code></para>
     <para>and set the following properties:</para>
-    <para><code>shared_buffers = 768MB</code></para>
-    <para>Determines how much memory PostgreSQL can use for caching of data. Is set too low by
-      default since it depends on kernel shared memory which is low on some operating systems.
-      Raising it to more than 1GB usually does not help performance so always keep it in this
-      range.</para>
+    <para><code>shared_buffers = 2000MB</code></para>
+    <para>Determines how much memory PostgreSQL can use for caching of data. This setting controls
+      how the size of the kernel shared memory which should be reserved for PostgreSQL.</para>
     <para><code>work_mem = 5MB</code></para>
     <para>Determines the amount of memory used for internal sort and hash operations. This setting
-      is per connection per query so a lot of memory may be consumed if raising this too
+      is per connection, per query so a lot of memory may be consumed if raising this too
       high.</para>
     <para><code>maintenance_work_mem = 256MB</code></para>
     <para>Determines the amount of memory PostgreSQL can use for maintenance operations such as
       creating indexes, running vacuum, adding foreign keys. Incresing this value might improve
       performance of index creation during the analytics and data mart generation processes.</para>
-    <para><code>effective_cache_size = 7000MB</code></para>
-    <para>An estimate of how much memory is available for caching (not an allocation) and is used by
-      PostgreSQL to determine whether a query plan will fit into the memory cache or not. Setting it
-      to a higher value than what is really available will result in poor performance.</para>
+    <para><code>effective_cache_size = 8000MB</code></para>
+    <para>An estimate of how much memory is available for disk caching by the operating system (not
+      an allocation) and is used by PostgreSQL to determine whether a query plan will fit into the
+      cache or not. Setting it to a higher value than what is really available will result in poor
+      performance. This value should be inclusive of the shared_buffers setting. PostgreSQL has two
+      layers of caching: The first layer uses the kernel shared memory and is controlled by the
+      shared_buffers setting. PostgreSQL delegates the second layer to the operating system disk
+      cache and the size of available memory can be given with the effective_cache_size
+      setting.</para>
     <para><code>checkpoint_segments = 32</code></para>
     <para>PostgreSQL writes new transactions to a log file called WAL segments which are 16MB in size. When a number of segments have been written a checkpoint occurs. Setting this number to a larger value will thus improve performance for write-heavy systems such as DHIS 2.</para>
     <para><code>checkpoint_completion_target = 0.8</code></para>
@@ -104,7 +114,7 @@
       AMD systems you might see <emphasis role="italic">/java-7-openjdk-amd64</emphasis> Note that
       you should adjust this to your environment:</para>
     <para><screen>export JAVA_HOME=&apos;/usr/lib/jvm/java-7-openjdk&apos;
-export JAVA_OPTS=&apos;-Xmx6000m -Xms3000m -XX:MaxPermSize=500m -XX:PermSize=300m&apos;
+export JAVA_OPTS=&apos;-Xmx7500m -Xms4000m -XX:MaxPermSize=500m -XX:PermSize=300m&apos;
 export DHIS2_HOME=&apos;/home/dhis/config&apos;</screen></para>
     <para>If you need to change the <emphasis role="italic">port</emphasis> of which Tomcat listens for requests you can open the Tomcat configuration file <emphasis role="italic">/conf/server.xml</emphasis>, locate the <emphasis role="italic">&lt;Connector&gt;</emphasis> element which is not commented out and change the <emphasis role="italic">port</emphasis> attribute value to the desired port number.</para>
     <para>To monitor the behavior of Tomcat the log is the primary source of information. The log can be easily viewed with the command <code>tail -f logs/catalina.out</code></para>