{"id":6776,"date":"2021-05-04T10:00:29","date_gmt":"2021-05-04T08:00:29","guid":{"rendered":"https:\/\/www.credativ.de\/blog\/credativ-inside\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/"},"modified":"2026-04-15T17:50:50","modified_gmt":"2026-04-15T15:50:50","slug":"moodle-postgresql-load-balancing-with-haproxy-and-patroni","status":"publish","type":"post","link":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/","title":{"rendered":"Moodle PostgreSQL load balancing with HAProxy and Patroni"},"content":{"rendered":"<p><a href=\"https:\/\/moodle.org\/\">Moodle<\/a> is a popular Open Source online learning platform. Especially since the beginning of the COVID-19 pandemic the importance of Moodle for schools and universities has further increased. In some states in Germany all schools had to switch to Moodle and other platforms like BigBlueButton in the course of a few days. This leads to scalability problems if suddenly several tens of thousands of pupils need to access Moodle.<br \/>\nBesides scaling the Moodle application itself, the database needs to be considered as well. One of the database options for Moodle is PostgreSQL. In this blog post, we present load-balancing options for Moodle using PostgreSQL.<\/p>\n<h2>High-Availability via Patroni<\/h2>\n<p>An online learning platform can be considered critical infrastructure from the point of view of the educational system and should be made highly available, in particular the database. A good solution for PostgreSQL is <a href=\"https:\/\/patroni.readthedocs.io\/en\/latest\/\">Patroni<\/a>, we reported on its <a href=\"https:\/\/www.credativ.de\/en\/blog\/howtos\/integrating-patroni-into-debian\/\">Debian-integration in the past<\/a>.<\/p>\n<p>In short, Patroni uses a distributed consensus store (DCS) to elect a leader from a typically 3-node cluster or initiate a failover and elect a new leader in the case of a leader failure, without entering a split-brain scenario. In addition, Patroni provides a REST API used for communication among nodes and from the <code>patronictl<\/code> program, e.g. to change the Postgres configuration online on all nodes or to initiate a switchover.<\/p>\n<h2>Client-solutions for high availability<\/h2>\n<p>From Moodle&#8217;s perspective, however, it must additionally be ensured that it is connected to the leader, otherwise no write transactions are possible. Traditional high-availability solutions such as Pacemaker use virtual IPs (VIPs) here, which are pivoted to the new primary node in the event of a failover. For Patroni there is the <a href=\"https:\/\/github.com\/cybertec-postgresql\/vip-manager\">vip-manager<\/a> project instead, which monitors the leader key in the DCS and sets or removes cluster VIP locally. This is also integrated into <a href=\"https:\/\/www.credativ.de\/en\/blog\/postgresql\/debian-integration-of-patroni-and-vip-manager\/\">Debian<\/a> as well.<\/p>\n<p>An alternative is to use client-side failover based on PostgreSQL&#8217;s <i>libpq<\/i> library. For this, all cluster members are listed in the connection string and the connection option <code>target_session_attrs=read-write<\/code> is added. Configured this way, if a connection is broken, the client will try to reach the other nodes until a new primary is found.<\/p>\n<p>Another option is <a href=\"http:\/\/www.haproxy.org\/\">HAProxy<\/a>, a highly scalable TCP\/HTTP load balancer. By performing periodic health checks on Patroni\u2018s REST API of each node, it can determine the current leader and forward client queries to it.<\/p>\n<h2>Moodle database configuration<\/h2>\n<p>Moodle&#8217;s connection to a PostgreSQL database is configured in <code>config.php<\/code>, e.g. for a simple stand-alone database:<\/p>\n<pre><code>$CFG-&gt;dbtype    = 'pgsql';\r\n$CFG-&gt;dblibrary = 'native';\r\n$CFG-&gt;dbhost    = '192.168.1.1';\r\n$CFG-&gt;dbname    = 'moodle';\r\n$CFG-&gt;dbuser    = 'moodle';\r\n$CFG-&gt;dbpass    = 'moodle';\r\n$CFG-&gt;prefix    = 'mdl_';\r\n$CFG-&gt;dboptions = array (\r\n  'dbport' =&gt; '',\r\n  'dbsocket' =&gt; ''\r\n);<\/code><\/pre>\n<p>The default port 5432 is used here.<\/p>\n<p>If streaming replication is used, the standbys can additionally be defined as <code>readonly<\/code> and assigned to an own database user (which only needs read permissions):<\/p>\n<pre><code>$CFG-&gt;dboptions = array (\r\n[...]\r\n  'readonly' =&gt; [\r\n    'instance' =&gt; [\r\n      [\r\n      'dbhost' =&gt; '192.168.1.2',\r\n      'dbport' =&gt;  '',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n      ],\r\n      [\r\n      'dbhost' =&gt; '192.168.1.3',\r\n      'dbport' =&gt;  '',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n      ]\r\n    ]\r\n  ]\r\n);<\/code><\/pre>\n<h2>Failover\/load balancing with libpq<\/h2>\n<p>If a highly available Postgres cluster is used with Patroni, the primary, as described above, can be switched to prevent loss of data or shutdown of the system, in case of a failover or switchover incident. Moodle does not provide a way to set generic database options here and thus setting <code>target_session_attrs=read-write<\/code> directly is not possible. Therefore we developed a <a href=\"https:\/\/github.com\/credativ\/moodle\/commit\/4add78137e98daa23c2fc1bf1d9bdfea6a991de8\">patch<\/a> for this and <a href=\"https:\/\/tracker.moodle.org\/browse\/MDL-70691\">implemented<\/a> it in the Moodle tracker. This allows the additional option <code>'dbfailover' =&gt; 1,<\/code> in the <code>$CFG-&gt;dboptions<\/code> array, which adds the necessary connection option <code>target_session_attrs=read-write<\/code>. A customized <code>config.php<\/code> would look like this:<\/p>\n<pre><code>$CFG-&gt;dbtype    = 'pgsql';\r\n$CFG-&gt;dblibrary = 'native';\r\n$CFG-&gt;dbhost    = '192.168.1.1,192.168.1.2,192.168.1.3';\r\n$CFG-&gt;dbname    = 'moodle';\r\n$CFG-&gt;dbuser    = 'moodle';\r\n$CFG-&gt;dbpass    = 'moodle';\r\n$CFG-&gt;prefix    = 'mdl_';\r\n$CFG-&gt;dboptions = array (\r\n  'dbfailover' =&gt; 1,\r\n  'dbport' =&gt; '',\r\n  'dbsocket' =&gt; '',\r\n  'readonly' =&gt; [\r\n    'instance' =&gt; [\r\n      [\r\n      'dbhost' =&gt; '192.168.1.1',\r\n      'dbport' =&gt;  '',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n      ],\r\n      [\r\n      'dbhost' =&gt; '192.168.1.2',\r\n      'dbport' =&gt;  '',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n      ],\r\n      [\r\n      'dbhost' =&gt; '192.168.1.3',\r\n      'dbport' =&gt;  '',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n      ]\r\n    ]\r\n  ]\r\n);<\/code><\/pre>\n<h2>Failover\/load balancing with HAProxy<\/h2>\n<p>If HAProxy is to be used instead, then <code>$CFG-&gt;dbhost<\/code> must be set to the HAProxy host e.g. <code>127.0.0.1<\/code> in case HAProxy is running locally on the Moodle server(s). Moreover a second port (e.g. 65432) can be defined for read queries, which is configured as <code>readonly<\/code> in <code>$CFG-&gt;dboptions<\/code>, same as the streaming replication standby above. The <code>config.php<\/code> would then look like this:<\/p>\n<pre><code>$CFG-&gt;dbtype    = 'pgsql';\r\n$CFG-&gt;dblibrary = 'native';\r\n$CFG-&gt;dbhost    = '127.0.0.1';\r\n$CFG-&gt;dbname    = 'moodle';\r\n$CFG-&gt;dbuser    = 'moodle';\r\n$CFG-&gt;dbpass    = 'moodle';\r\n$CFG-&gt;prefix    = 'mdl_';\r\n$CFG-&gt;dboptions = array (\r\n  'dbport' =&gt; '',\r\n  'dbsocket' =&gt; '',\r\n  'readonly' =&gt; [\r\n    'instance' =&gt; [\r\n      'dbhost' =&gt; '127.0.0.1',\r\n      'dbport' =&gt;  '65432',\r\n      'dbuser' =&gt; 'moodle_safereads',\r\n      'dbpass' =&gt; 'moodle'\r\n    ]\r\n  ]\r\n);<\/code><\/pre>\n<p>The HAProxy configuration file <code>haproxy.cfg<\/code> can look like the following example:<\/p>\n<pre><code>global\r\n    maxconn 100\r\n\r\ndefaults\r\n    log global\r\n    mode tcp\r\n    retries 2\r\n    timeout client 30m\r\n    timeout connect 4s\r\n    timeout server 30m\r\n    timeout check 5s\r\n\r\nlisten stats\r\n    mode http\r\n    bind *:7000\r\n    stats enable\r\n    stats uri \/\r\n\r\nlisten postgres_write\r\n    bind *:5432\r\n    mode tcp\r\n    option httpchk\r\n    http-check expect status 200\r\n    default-server inter 3s fall 3 rise 3 on-marked-down shutdown-sessions\r\n    server pg1 192.168.1.1:5432 maxconn 100 check port 8008\r\n    server pg2 192.168.1.2:5432 maxconn 100 check port 8008\r\n    server pg3 192.168.1.3:5432 maxconn 100 check port 8008<\/code><\/pre>\n<p>HAProxy expects incoming write connections (<code>postgres_write<\/code>) on port 5432 and forwards them to port 5432 of the cluster members. The primary is determined by an HTTP check on port 8008 (the default Patroni REST API port); Patroni returns status 200 here for the primary and status 503 for standbys.<\/p>\n<p>For read queries (<code>postgres_read<\/code>), it must be decided whether the primary should also serve read-only queries or not. If this is the case, a simple Postgres check (<code>pgsql-check<\/code>) can be used; however, this may lead to entries in the PostgreSQL log regarding incorrect or incomplete logins:<\/p>\n<pre><code>listen postgres_read\r\n    bind *:65432\r\n    mode tcp\r\n    balance leastconn\r\n    option pgsql-check user haproxy\r\n    default-server inter 3s fall 3 rise 3 on-marked-down shutdown-sessions\r\n    server pg1 192.168.1.1:5432 check\r\n    server pg2 192.168.1.2:5432 check\r\n    server pg3 192.168.1.3:5432 check<\/code><\/pre>\n<p>If you don&#8217;t want the primary to participate in the read scaling you can simply use the same HTTP check as in the <code>postgres_write<\/code> section, this time expecting HTTP status 503:<\/p>\n<pre><code>listen postgres_read\r\n    bind *:65432\r\n    mode tcp\r\n    balance leastconn\r\n    option httpchk\r\n    http-check expect status 503\r\n    default-server inter 3s fall 3 rise 3 on-marked-down shutdown-sessions\r\n    server pg1 192.168.1.1:5432 check port 8008\r\n    server pg2 192.168.1.2:5432 check port 8008\r\n    server pg3 192.168.1.3:5432 check port 8008<\/code><\/pre>\n<h2>Revised Ansible playbook<\/h2>\n<p>HAProxy support has also been implemented in <a href=\"https:\/\/github.com\/credativ\/ansible-playbook-patroni-debian\/releases\/tag\/v0.3\">version 0.3<\/a> of our <a href=\"https:\/\/github.com\/credativ\/ansible-playbook-patroni-debian\">Ansible playbooks<\/a> for automated setup of a three-node PostgreSQL Patroni cluster on Debian. The new variable <code>haproxy_primary_read_scale<\/code> can be used to decide whether HAProxy should also issue requests on the read-only port to the primary node or only to the followers.<\/p>\n<h2>We are happy to help!<\/h2>\n<p>Whether it&#8217;s PostgreSQL, Patroni, HAProxy, Moodle, or any other open source software; with over 22+ years of development and service experience in the open source space, credativ GmbH can assist you with unparalleled and individually customizable support. We are there to help and assist you in all your open source infrastructure needs \u2013 if desired 24 hours a day, 365 days a year!<\/p>\n<p>We look forward to <a href=\"https:\/\/www.credativ.de\/%C3%BCber-credativ\/kontakt\">hearing<\/a> from you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Moodle is a popular Open Source online learning platform. Especially since the beginning of the COVID-19 pandemic the importance of Moodle for schools and universities has further increased. In some states in Germany all schools had to switch to Moodle and other platforms like BigBlueButton in the course of a few days. This leads to [&hellip;]<\/p>\n","protected":false},"author":37,"featured_media":6156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_improvement_type_select":"improve_an_existing","_thumb_yes_seoaic":false,"_frame_yes_seoaic":false,"seoaic_generate_description":"","seoaic_improve_instructions_prompt":"","seoaic_rollback_content_improvement":"","seoaic_idea_thumbnail_generator":"","thumbnail_generated":false,"thumbnail_generate_prompt":"","seoaic_article_description":"","seoaic_article_subtitles":[],"footnotes":""},"categories":[1708],"tags":[1826,1870,1798,1887,1801],"class_list":["post-6776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql-en","tag-haproxy-en","tag-moodle-en","tag-patroni-en","tag-planetpostgresql","tag-postgresql-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Moodle PostgreSQL load balancing with HAProxy and Patroni - credativ\u00ae<\/title>\n<meta name=\"description\" content=\"Optimize Moodle&#039;s performance with PostgreSQL load balancing. Learn how to ensure scalability.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moodle PostgreSQL load balancing with HAProxy and Patroni\" \/>\n<meta property=\"og:description\" content=\"Optimize Moodle&#039;s performance with PostgreSQL load balancing. Learn how to ensure scalability.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/\" \/>\n<meta property=\"og:site_name\" content=\"credativ\u00ae\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/credativDE\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-04T08:00:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-15T15:50:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2500\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Banck\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@credativde\" \/>\n<meta name=\"twitter:site\" content=\"@credativde\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Banck\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/\"},\"author\":{\"name\":\"Michael Banck\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/038c79105ce9b5fd885631da3f806698\"},\"headline\":\"Moodle PostgreSQL load balancing with HAProxy and Patroni\",\"datePublished\":\"2021-05-04T08:00:29+00:00\",\"dateModified\":\"2026-04-15T15:50:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/\"},\"wordCount\":860,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg\",\"keywords\":[\"haproxy\",\"moodle\",\"Patroni\",\"planetpostgresql\",\"PostgreSQL\u00ae\"],\"articleSection\":[\"PostgreSQL\u00ae\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#respond\"]}],\"copyrightYear\":\"2021\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/\",\"name\":\"Moodle PostgreSQL load balancing with HAProxy and Patroni - credativ\u00ae\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg\",\"datePublished\":\"2021-05-04T08:00:29+00:00\",\"dateModified\":\"2026-04-15T15:50:50+00:00\",\"description\":\"Optimize Moodle's performance with PostgreSQL load balancing. Learn how to ensure scalability.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg\",\"width\":2500,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Moodle PostgreSQL load balancing with HAProxy and Patroni\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"name\":\"credativ GmbH\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Organization\",\"Place\"],\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\",\"name\":\"credativ\u00ae\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"logo\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#local-main-organization-logo\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#local-main-organization-logo\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/credativDE\\\/\",\"https:\\\/\\\/x.com\\\/credativde\",\"https:\\\/\\\/mastodon.social\\\/@credativde\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/credativ-gmbh\",\"https:\\\/\\\/www.instagram.com\\\/credativ\\\/\"],\"description\":\"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\\\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.\",\"legalName\":\"credativ GmbH\",\"foundingDate\":\"2025-03-01\",\"duns\":\"316387060\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"},\"address\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#local-main-place-address\"},\"geo\":{\"@type\":\"GeoCoordinates\",\"latitude\":\"51.1732374\",\"longitude\":\"6.392010099999999\"},\"telephone\":[\"+4921619174200\",\"08002733284\"],\"contactPoint\":{\"@type\":\"ContactPoint\",\"telephone\":\"08002733284\",\"email\":\"vertrieb@credativ.de\"},\"openingHoursSpecification\":[{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\"],\"opens\":\"09:00\",\"closes\":\"17:00\"},{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Saturday\",\"Sunday\"],\"opens\":\"00:00\",\"closes\":\"00:00\"}],\"email\":\"info@credativ.de\",\"areaServed\":\"D-A-CH\",\"vatID\":\"DE452151696\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/038c79105ce9b5fd885631da3f806698\",\"name\":\"Michael Banck\",\"description\":\"Michael Banck ist seit 2009 Mitarbeiter der credativ GmbH, sowie seit 2001 Mitglied des Debian Projekts und auch in weiteren Open Source Projekten aktiv. Als Mitglied des Datenbank-Teams von credativ hat er in den letzten Jahren verschiedene Kunden bei der L\u00f6sung von Problemen mit und dem t\u00e4glichen Betrieb von PostgreSQL\u00ae, sowie bei der Einf\u00fchrung von Hochverf\u00fcgbarkeits-L\u00f6sungen im Bereich Datenbanken unterst\u00fctzt und beraten.\"},{\"@type\":\"PostalAddress\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#local-main-place-address\",\"streetAddress\":\"Hennes-Weisweiler-Allee 23\",\"addressLocality\":\"M\u00f6nchengladbach\",\"postalCode\":\"41179\",\"addressRegion\":\"Deutschland\",\"addressCountry\":\"DE\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/postgresql\\\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\\\/#local-main-organization-logo\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"caption\":\"credativ\u00ae\"}]}<\/script>\n<meta name=\"geo.placename\" content=\"M\u00f6nchengladbach\" \/>\n<meta name=\"geo.position\" content=\"51.1732374;6.392010099999999\" \/>\n<meta name=\"geo.region\" content=\"Germany\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Moodle PostgreSQL load balancing with HAProxy and Patroni - credativ\u00ae","description":"Optimize Moodle's performance with PostgreSQL load balancing. Learn how to ensure scalability.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/","og_locale":"en_US","og_type":"article","og_title":"Moodle PostgreSQL load balancing with HAProxy and Patroni","og_description":"Optimize Moodle's performance with PostgreSQL load balancing. Learn how to ensure scalability.","og_url":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/","og_site_name":"credativ\u00ae","article_publisher":"https:\/\/www.facebook.com\/credativDE\/","article_published_time":"2021-05-04T08:00:29+00:00","article_modified_time":"2026-04-15T15:50:50+00:00","og_image":[{"width":2500,"height":300,"url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg","type":"image\/jpeg"}],"author":"Michael Banck","twitter_card":"summary_large_image","twitter_creator":"@credativde","twitter_site":"@credativde","twitter_misc":{"Written by":"Michael Banck","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#article","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/"},"author":{"name":"Michael Banck","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/038c79105ce9b5fd885631da3f806698"},"headline":"Moodle PostgreSQL load balancing with HAProxy and Patroni","datePublished":"2021-05-04T08:00:29+00:00","dateModified":"2026-04-15T15:50:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/"},"wordCount":860,"commentCount":0,"publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg","keywords":["haproxy","moodle","Patroni","planetpostgresql","PostgreSQL\u00ae"],"articleSection":["PostgreSQL\u00ae"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#respond"]}],"copyrightYear":"2021","copyrightHolder":{"@id":"https:\/\/www.credativ.de\/#organization"}},{"@type":"WebPage","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/","url":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/","name":"Moodle PostgreSQL load balancing with HAProxy and Patroni - credativ\u00ae","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#primaryimage"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg","datePublished":"2021-05-04T08:00:29+00:00","dateModified":"2026-04-15T15:50:50+00:00","description":"Optimize Moodle's performance with PostgreSQL load balancing. Learn how to ensure scalability.","breadcrumb":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#primaryimage","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2021\/12\/Moodle-PostgreSQL-Load-Balancing-mit-HAProxy-und-Patroni-Header-copy.jpg","width":2500,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.credativ.de\/en\/"},{"@type":"ListItem","position":2,"name":"Moodle PostgreSQL load balancing with HAProxy and Patroni"}]},{"@type":"WebSite","@id":"https:\/\/www.credativ.de\/en\/#website","url":"https:\/\/www.credativ.de\/en\/","name":"credativ GmbH","description":"","publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.credativ.de\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Organization","Place"],"@id":"https:\/\/www.credativ.de\/en\/#organization","name":"credativ\u00ae","url":"https:\/\/www.credativ.de\/en\/","logo":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#local-main-organization-logo"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#local-main-organization-logo"},"sameAs":["https:\/\/www.facebook.com\/credativDE\/","https:\/\/x.com\/credativde","https:\/\/mastodon.social\/@credativde","https:\/\/www.linkedin.com\/company\/credativ-gmbh","https:\/\/www.instagram.com\/credativ\/"],"description":"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.","legalName":"credativ GmbH","foundingDate":"2025-03-01","duns":"316387060","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"},"address":{"@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#local-main-place-address"},"geo":{"@type":"GeoCoordinates","latitude":"51.1732374","longitude":"6.392010099999999"},"telephone":["+4921619174200","08002733284"],"contactPoint":{"@type":"ContactPoint","telephone":"08002733284","email":"vertrieb@credativ.de"},"openingHoursSpecification":[{"@type":"OpeningHoursSpecification","dayOfWeek":["Monday","Tuesday","Wednesday","Thursday","Friday"],"opens":"09:00","closes":"17:00"},{"@type":"OpeningHoursSpecification","dayOfWeek":["Saturday","Sunday"],"opens":"00:00","closes":"00:00"}],"email":"info@credativ.de","areaServed":"D-A-CH","vatID":"DE452151696"},{"@type":"Person","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/038c79105ce9b5fd885631da3f806698","name":"Michael Banck","description":"Michael Banck ist seit 2009 Mitarbeiter der credativ GmbH, sowie seit 2001 Mitglied des Debian Projekts und auch in weiteren Open Source Projekten aktiv. Als Mitglied des Datenbank-Teams von credativ hat er in den letzten Jahren verschiedene Kunden bei der L\u00f6sung von Problemen mit und dem t\u00e4glichen Betrieb von PostgreSQL\u00ae, sowie bei der Einf\u00fchrung von Hochverf\u00fcgbarkeits-L\u00f6sungen im Bereich Datenbanken unterst\u00fctzt und beraten."},{"@type":"PostalAddress","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#local-main-place-address","streetAddress":"Hennes-Weisweiler-Allee 23","addressLocality":"M\u00f6nchengladbach","postalCode":"41179","addressRegion":"Deutschland","addressCountry":"DE"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/postgresql\/moodle-postgresql-load-balancing-with-haproxy-and-patroni\/#local-main-organization-logo","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","caption":"credativ\u00ae"}]},"geo.placename":"M\u00f6nchengladbach","geo.position":{"lat":"51.1732374","long":"6.392010099999999"},"geo.region":"Germany"},"_links":{"self":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/comments?post=6776"}],"version-history":[{"count":1,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6776\/revisions"}],"predecessor-version":[{"id":18155,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/6776\/revisions\/18155"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/media\/6156"}],"wp:attachment":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/media?parent=6776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/categories?post=6776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/tags?post=6776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}