<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Emmanuel Bosquet, Author at Clever Cloud</title>
	<atom:link href="https://www.clever.cloud/blog/author/emmanuel-bosquetclever-cloud-com/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>From Code to Product</description>
	<lastBuildDate>Mon, 09 Oct 2023 15:11:28 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://cdn.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>Emmanuel Bosquet, Author at Clever Cloud</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Open sourcing Sōzu connectors</title>
		<link>https://www.clever.cloud/blog/engineering/2023/09/25/reverse-proxy-open-sourcing-sozu-connectors/</link>
		
		<dc:creator><![CDATA[Emmanuel Bosquet]]></dc:creator>
		<pubDate>Mon, 25 Sep 2023 15:19:04 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[reverse proxy]]></category>
		<guid isPermaLink="false">https://www.clever-cloud.com/?p=10297</guid>

					<description><![CDATA[<p><img width="573" height="266" src="https://cdn.clever-cloud.com/uploads/2023/09/clever-cloud-devoile-ses-connecteurs-sozu-open-source-3.svg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="clever cloud devoile ses connecteurs sozu open source 3" decoding="async" fetchpriority="high" /></p><!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8027,"mediaLink":"https://www.clever.cloud/?attachment_id=8027","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p>Clever Cloud is today the main developer of <a href="https://www.sozu.io/">Sōzu</a>, a Reverse Proxy that was developped at Clever Cloud, in <a href="https://www.clever.cloud/blog/engineering/2016/11/02/falling-for-rust/">Rust</a>, to meet the needs of our infrastructure for performance and hot reloading. Sōzu is used throughout Clever Cloud, paired with HAProxy, to route traffic to our customer's applications.</p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/canvas-1-358x447.png" alt="" class="wp-image-8027 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading"><strong>What we used to do: </strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Up until now, our Reverse Proxy Sōzu used to be managed by Clever Cloud by a closed source program that ran on the same machine and assumed two big responsibilities:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Firstly, listen to a RabbitMQ topic and redirect requests to Sōzu (via its UNIX socket)</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Secondly, watch over a PKI directory (Public Key Infrastructure) to redirect TLS certificates to Sōzu (via its UNIX socket)</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading"><strong>Turning open source</strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While working on a new Prometheus connector for Sōzu, we realized we could open source it. With this realization came the idea of porting the logic of the former Sōzu manager (described above) from its closed source state into new open source repositories.<br>What we ultimately aim to develop is an entirely <strong>open-source</strong> <strong>ecosystem around our Reverse Proxy Sōzu</strong>.<br>This blog post details what these new open source components are, and summarizes what they do.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Our open-source ecosystem around <strong>Sōzu</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-prometheus-connector" target="_blank" rel="noreferrer noopener">Sōzu Prometheus connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8023,"mediaLink":"https://www.clever.cloud/?attachment_id=8023","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p><a href="https://prometheus.io/docs/introduction/overview/" target="_blank" rel="noreferrer noopener">Prometheus</a> is a monitoring and alerting software suite.<br>This simple connector operates alongside Sōzu. It waits for HTTP requests on the <code>/metrics</code> route, queries Sōzu for its metrics, formats the metrics to be Prometheus-compatible, and sends them in the HTTP&nbsp;response.<br>This means that <strong>Prometheus metrics are readily available on the IP address of a Sōzu machine.</strong></p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/1200px-Prometheus_software_logo.svg_-1024x1015-1-451x447.png" alt="" class="wp-image-8023 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-pulsar-connector" target="_blank" rel="noreferrer noopener">Sōzu Pulsar connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8025,"mediaLink":"https://www.clever.cloud/?attachment_id=8025","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p><a href="https://github.com/CleverCloud/sozu-pulsar-connector" target="_blank" rel="noreferrer noopener">Apache Pulsar</a> is a highly scalable messaging platform. We use it extensively at Clever Cloud because of its distributed aspect and cutting-edge throughput performance.<br>The Sōzu Pulsar connector subscribes to a Pulsar topic and transmits messages to Sōzu. Sōzu uses these messages to perform hot reloading on the proxy, which is a key feature of our Reverse Proxy.<br>What it means for us and anyone using the Sōzu ecosystem: this connector enables <strong>updating traffic redirection in real time.</strong></p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/1_7F-rMchWXbujnBT7QUN4zA-1.jpeg" alt="" class="wp-image-8025 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-pki-connector" target="_blank" rel="noreferrer noopener">Sōzu PKI connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8026,"mediaLink":"https://www.clever.cloud/?attachment_id=8026","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p>PKI stands for Public Key Infrastructure, an omnipresent security framework on the Internet, typically used for securing connections with HTTPS (among other things). In the PKI framework, Sōzu functions as a <strong>TLS endpoint</strong>: it decrypts HTTPS traffic into HTTP traffic.<br>The Sōzu PKI connector runs alongside Sōzu, watches over a given directory in the file system, reads TLS certificates that were put there by either human or machine, and transmits them to Sōzu.<br>Then , what this ultimately means is: <strong>write a TLS certificate on the machine, Sōzu will have it.</strong> </p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/TLS_icon-e1586274007843.png" alt="" class="wp-image-8026 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:paragraph {"fontSize":"large"} -->
<p class="has-large-font-size"><a href="https://github.com/CleverCloud/sozu-client">Sōzu client</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is a code library used by all above connectors. It pools connections to Sōzu's UNIX socket and functions entirely asynchronously. All in all, it makes <strong>writing new connectors easier</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>What's next</strong><br>The best thing we wish is for the open-source community to join us in using and improving Sōzu as it goes. Our end-game is to build a web UI to manage a Sōzu instance in the navigator.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><br></p>
<!-- /wp:paragraph -->]]></description>
										<content:encoded><![CDATA[<p><img width="573" height="266" src="https://cdn.clever-cloud.com/uploads/2023/09/clever-cloud-devoile-ses-connecteurs-sozu-open-source-3.svg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="clever cloud devoile ses connecteurs sozu open source 3" decoding="async" /></p><!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8027,"mediaLink":"https://www.clever.cloud/?attachment_id=8027","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p>Clever Cloud is today the main developer of <a href="https://www.sozu.io/">Sōzu</a>, a Reverse Proxy that was developped at Clever Cloud, in <a href="https://www.clever.cloud/blog/engineering/2016/11/02/falling-for-rust/">Rust</a>, to meet the needs of our infrastructure for performance and hot reloading. Sōzu is used throughout Clever Cloud, paired with HAProxy, to route traffic to our customer's applications.</p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/canvas-1-358x447.png" alt="" class="wp-image-8027 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading"><strong>What we used to do: </strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Up until now, our Reverse Proxy Sōzu used to be managed by Clever Cloud by a closed source program that ran on the same machine and assumed two big responsibilities:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Firstly, listen to a RabbitMQ topic and redirect requests to Sōzu (via its UNIX socket)</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Secondly, watch over a PKI directory (Public Key Infrastructure) to redirect TLS certificates to Sōzu (via its UNIX socket)</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading"><strong>Turning open source</strong></h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While working on a new Prometheus connector for Sōzu, we realized we could open source it. With this realization came the idea of porting the logic of the former Sōzu manager (described above) from its closed source state into new open source repositories.<br>What we ultimately aim to develop is an entirely <strong>open-source</strong> <strong>ecosystem around our Reverse Proxy Sōzu</strong>.<br>This blog post details what these new open source components are, and summarizes what they do.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Our open-source ecosystem around <strong>Sōzu</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-prometheus-connector" target="_blank" rel="noreferrer noopener">Sōzu Prometheus connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8023,"mediaLink":"https://www.clever.cloud/?attachment_id=8023","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p><a href="https://prometheus.io/docs/introduction/overview/" target="_blank" rel="noreferrer noopener">Prometheus</a> is a monitoring and alerting software suite.<br>This simple connector operates alongside Sōzu. It waits for HTTP requests on the <code>/metrics</code> route, queries Sōzu for its metrics, formats the metrics to be Prometheus-compatible, and sends them in the HTTP&nbsp;response.<br>This means that <strong>Prometheus metrics are readily available on the IP address of a Sōzu machine.</strong></p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/1200px-Prometheus_software_logo.svg_-1024x1015-1-451x447.png" alt="" class="wp-image-8023 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-pulsar-connector" target="_blank" rel="noreferrer noopener">Sōzu Pulsar connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8025,"mediaLink":"https://www.clever.cloud/?attachment_id=8025","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p><a href="https://github.com/CleverCloud/sozu-pulsar-connector" target="_blank" rel="noreferrer noopener">Apache Pulsar</a> is a highly scalable messaging platform. We use it extensively at Clever Cloud because of its distributed aspect and cutting-edge throughput performance.<br>The Sōzu Pulsar connector subscribes to a Pulsar topic and transmits messages to Sōzu. Sōzu uses these messages to perform hot reloading on the proxy, which is a key feature of our Reverse Proxy.<br>What it means for us and anyone using the Sōzu ecosystem: this connector enables <strong>updating traffic redirection in real time.</strong></p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/1_7F-rMchWXbujnBT7QUN4zA-1.jpeg" alt="" class="wp-image-8025 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:heading {"level":3,"fontSize":"large"} -->
<h3 class="wp-block-heading has-large-font-size"><a href="https://github.com/CleverCloud/sozu-pki-connector" target="_blank" rel="noreferrer noopener">Sōzu PKI connector</a></h3>
<!-- /wp:heading -->

<!-- wp:media-text {"align":"wide","mediaPosition":"right","mediaId":8026,"mediaLink":"https://www.clever.cloud/?attachment_id=8026","mediaType":"image","mediaWidth":15} -->
<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 15%"><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…"} -->
<p>PKI stands for Public Key Infrastructure, an omnipresent security framework on the Internet, typically used for securing connections with HTTPS (among other things). In the PKI framework, Sōzu functions as a <strong>TLS endpoint</strong>: it decrypts HTTPS traffic into HTTP traffic.<br>The Sōzu PKI connector runs alongside Sōzu, watches over a given directory in the file system, reads TLS certificates that were put there by either human or machine, and transmits them to Sōzu.<br>Then , what this ultimately means is: <strong>write a TLS certificate on the machine, Sōzu will have it.</strong> </p>
<!-- /wp:paragraph --></div><figure class="wp-block-media-text__media"><img src="https://cdn.clever-cloud.com/uploads/2023/07/TLS_icon-e1586274007843.png" alt="" class="wp-image-8026 size-full"/></figure></div>
<!-- /wp:media-text -->

<!-- wp:paragraph {"fontSize":"large"} -->
<p class="has-large-font-size"><a href="https://github.com/CleverCloud/sozu-client">Sōzu client</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is a code library used by all above connectors. It pools connections to Sōzu's UNIX socket and functions entirely asynchronously. All in all, it makes <strong>writing new connectors easier</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>What's next</strong><br>The best thing we wish is for the open-source community to join us in using and improving Sōzu as it goes. Our end-game is to build a web UI to manage a Sōzu instance in the navigator.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><br></p>
<!-- /wp:paragraph -->]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Pgpool-II: getting the most of PostgreSQL</title>
		<link>https://www.clever.cloud/blog/features/2021/07/07/introducing-pgpool-ii/</link>
		
		<dc:creator><![CDATA[Emmanuel Bosquet]]></dc:creator>
		<pubDate>Wed, 07 Jul 2021 09:04:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[pgpool]]></category>
		<category><![CDATA[postgresql]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2021/07/07/introducing-pgpool-ii/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="pg pool2 1" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-1368x528.jpg 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p>Are you having too many simultaneous connections on your PostgreSQL database? Do you dream of balancing the load of your requests across a PostgreSQL cluster? Either way, we've got the solution for you.

Clever Cloud is proud to introduce the native support of Pgpool-II on all application instances, for no additional fee.

<span id="more-3001"></span>

<a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool">See the Clever Cloud documentation on Pgpool-II</a>.
<h2 id="what-is-pgpool-ii">What is Pgpool-II?</h2>
It is a middleware that comes in between your application and your PostgreSQL database (<a href="https://www.pgpool.net/mediawiki/index.php/Main_Page">official website</a>). As its name suggests, it <em>pools</em> your app's connections to PostgreSQL, by saving and reusing them, and letting them wait when they are too many.

Pgpool-II also serves as a load balancer for PostgreSQL replicas for superior scaling. More on this below.

Pgpool-II now works out of the box on all Clever Cloud machines. Only exception: if you use docker, you'll have to configure the Dockerfile yourself.
<h2 id="no-more-connection-refused">No more <code>connection refused</code></h2>
Pgpool-II overall smoothens the use of PostgreSQL.
<ul>
 	<li><strong>Accessed on a Unix socket</strong>: faster than a TCP socket. Gotta chase those nanoseconds.</li>
 	<li><strong>Connection reuse</strong>: Pgpool saves connections and reuses them when similar ones come in (same user, same database…).</li>
 	<li><strong>Managing exceeding connections</strong>: Normally, PostgreSQL takes only so many concurrent connections, and discards any additional ones, which compromises the app. Pgpool-II, instead, queues the excess connections for later. No more <code>connection refused</code>.</li>
</ul>
<h2 id="what-do-i-have-to-do">What do I have to do?</h2>
Barely anything. By changing only one environment variable in your code, your app will send its requests to Pgpool-II directly.

In a typical PHP app, you would connect to a PostgreSQL add-on by doing:
<pre><code class="language-PHP">$host = getenv("POSTGRESQL_ADDON_HOST");
</code></pre>
You just need to change that into:
<pre><code class="language-PHP">$host = getenv("CC_PGPOOL_SOCKET_PATH");
</code></pre>
That's all there is to change in your code. User, password, all other calls to environment variables remain the same. See <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool/#usage">the doc</a> for details.

Now in the Clever Cloud Console, go to your app's environment variables, set <code>CC_ENABLE_PGPOOL</code> to <code>true</code>, and you're good to go!
<h2 id="load-balancing-lets-go-big">Load balancing: let's go big</h2>
Suppose your web app is BIG. You've got a few <code>INSERT</code> queries to make (registering a new customer for instance), and a ton of <code>SELECT</code> queries (searches, filling pages with products, you name it). It becomes wise to create <em>replicas</em> of your database, a PostgreSQL feature. These identical instances, called <em>followers</em>, are exact copycats of your <em>leader</em> database. On the graph they are called <em>primary</em> and <em>standby</em>, respectively. There can be several <em>standby</em> nodes.

<center>
<img style="width: 600px;" src="https://cdn.clever-cloud.com/uploads/2021/08/pgpool.png" /></center>

Pgpool-II will direct the <strong>write queries</strong> to the <em>primary</em>, and dispatch the <strong>read queries</strong> to the <em>standby</em> nodes, thus balancing the load and increasing throughput.

More details <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool/#how-to-configure-pgpool-ii">in the doc</a>. All you have to do is create as many PostgreSQL add-ons as you want replicas, and ask us to do the plumbing for you.]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="pg pool2 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/07/pg-pool2-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p>Are you having too many simultaneous connections on your PostgreSQL database? Do you dream of balancing the load of your requests across a PostgreSQL cluster? Either way, we've got the solution for you.

Clever Cloud is proud to introduce the native support of Pgpool-II on all application instances, for no additional fee.

<span id="more-3001"></span>

<a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool">See the Clever Cloud documentation on Pgpool-II</a>.
<h2 id="what-is-pgpool-ii">What is Pgpool-II?</h2>
It is a middleware that comes in between your application and your PostgreSQL database (<a href="https://www.pgpool.net/mediawiki/index.php/Main_Page">official website</a>). As its name suggests, it <em>pools</em> your app's connections to PostgreSQL, by saving and reusing them, and letting them wait when they are too many.

Pgpool-II also serves as a load balancer for PostgreSQL replicas for superior scaling. More on this below.

Pgpool-II now works out of the box on all Clever Cloud machines. Only exception: if you use docker, you'll have to configure the Dockerfile yourself.
<h2 id="no-more-connection-refused">No more <code>connection refused</code></h2>
Pgpool-II overall smoothens the use of PostgreSQL.
<ul>
 	<li><strong>Accessed on a Unix socket</strong>: faster than a TCP socket. Gotta chase those nanoseconds.</li>
 	<li><strong>Connection reuse</strong>: Pgpool saves connections and reuses them when similar ones come in (same user, same database…).</li>
 	<li><strong>Managing exceeding connections</strong>: Normally, PostgreSQL takes only so many concurrent connections, and discards any additional ones, which compromises the app. Pgpool-II, instead, queues the excess connections for later. No more <code>connection refused</code>.</li>
</ul>
<h2 id="what-do-i-have-to-do">What do I have to do?</h2>
Barely anything. By changing only one environment variable in your code, your app will send its requests to Pgpool-II directly.

In a typical PHP app, you would connect to a PostgreSQL add-on by doing:
<pre><code class="language-PHP">$host = getenv("POSTGRESQL_ADDON_HOST");
</code></pre>
You just need to change that into:
<pre><code class="language-PHP">$host = getenv("CC_PGPOOL_SOCKET_PATH");
</code></pre>
That's all there is to change in your code. User, password, all other calls to environment variables remain the same. See <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool/#usage">the doc</a> for details.

Now in the Clever Cloud Console, go to your app's environment variables, set <code>CC_ENABLE_PGPOOL</code> to <code>true</code>, and you're good to go!
<h2 id="load-balancing-lets-go-big">Load balancing: let's go big</h2>
Suppose your web app is BIG. You've got a few <code>INSERT</code> queries to make (registering a new customer for instance), and a ton of <code>SELECT</code> queries (searches, filling pages with products, you name it). It becomes wise to create <em>replicas</em> of your database, a PostgreSQL feature. These identical instances, called <em>followers</em>, are exact copycats of your <em>leader</em> database. On the graph they are called <em>primary</em> and <em>standby</em>, respectively. There can be several <em>standby</em> nodes.

<center>
<img style="width: 600px;" src="https://cdn.clever-cloud.com/uploads/2021/08/pgpool.png" /></center>

Pgpool-II will direct the <strong>write queries</strong> to the <em>primary</em>, and dispatch the <strong>read queries</strong> to the <em>standby</em> nodes, thus balancing the load and increasing throughput.

More details <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/pgpool/#how-to-configure-pgpool-ii">in the doc</a>. All you have to do is create as many PostgreSQL add-ons as you want replicas, and ask us to do the plumbing for you.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
