<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Drupal WxT – Performance</title><link>https://drupalwxt.github.io/docs/development/performance/</link><description>Recent content in Performance on Drupal WxT</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://drupalwxt.github.io/docs/development/performance/index.xml" rel="self" type="application/rss+xml"/><item><title>Docs: PostgreSQL</title><link>https://drupalwxt.github.io/docs/development/performance/postgresql/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupalwxt.github.io/docs/development/performance/postgresql/</guid><description>
&lt;p>To properly configure PostgreSQL with Drupal you should ensure the following configuration is used.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note&lt;/strong>: Some customizations might be necessary depending on your individual requirements.&lt;/p>
&lt;/blockquote>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>postgresqlConfiguration:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> listenAddresses: &lt;span style="color:#4e9a06">&amp;#34;&amp;#39;*&amp;#39;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxConnections: &lt;span style="color:#4e9a06">&amp;#34;200&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sharedBuffers: 512MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> workMem: 2048MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> effectiveCacheSize: 512MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> effectiveIoConcurrency: &lt;span style="color:#4e9a06">&amp;#34;100&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maintenanceWorkMem: 32MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> minWalSize: 512MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxWalSize: 512MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walBuffers: 8048kB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> byteaOutput: &lt;span style="color:#4e9a06">&amp;#34;&amp;#39;escape&amp;#39;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> hugePages: &lt;span style="color:#4e9a06">&amp;#34;off&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walLevel: &lt;span style="color:#4e9a06">&amp;#34;replica&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxWalSenders: &lt;span style="color:#4e9a06">&amp;#34;0&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> synchronousCommit: &lt;span style="color:#4e9a06">&amp;#34;on&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walKeepSegments: &lt;span style="color:#4e9a06">&amp;#34;130&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> checkpointTimeout: &lt;span style="color:#4e9a06">&amp;#34;&amp;#39;15 min&amp;#39;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> checkpointCompletionTarget: &lt;span style="color:#4e9a06">&amp;#34;0.9&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walCompression: &lt;span style="color:#4e9a06">&amp;#34;on&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walWriterDelay: 200ms
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> walWriterFlushAfter: 1MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> bgwriterDelay: 200ms
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> bgwriterLruMaxpages: &lt;span style="color:#4e9a06">&amp;#34;100&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> bgwriterLruMultiplier: &lt;span style="color:#4e9a06">&amp;#34;2.0&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> bgwriterFlushAfter: &lt;span style="color:#4e9a06">&amp;#34;0&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxWorkerProcesses: &lt;span style="color:#4e9a06">&amp;#34;8&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxParallelWorkersPerGather: &lt;span style="color:#4e9a06">&amp;#34;4&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> maxParallelWorkers: &lt;span style="color:#4e9a06">&amp;#34;4&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>&lt;strong>Note&lt;/strong>: The above is written in yaml syntax which will work for both Docker Compose and Kubernetes Helm Charts. For the &lt;code>postgresql.conf&lt;/code> file itself without using these tools simply find the &lt;code>_&lt;/code> counterpart.&lt;/p>
&lt;/blockquote>
&lt;h4 id="queries-leveraging-ilike">Queries leveraging ILIKE&lt;/h4>
&lt;p>There is a known PostgreSQL performance issue that exists in Drupal and is related to leveraging queries with &lt;code>ILIKE&lt;/code>.&lt;/p>
&lt;p>This issue is particularly noticeable in relation to the path_alias table.&lt;/p>
&lt;p>There are patches being worked on to handle this in Drupal core but a very quick fix can be implemented leveraging pg_trgm.&lt;/p>
&lt;p>There is a great blog article listed below which goes over this issue in more detail.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;a href="https://ferfebles.github.io/2018/04/16/Improving-large-Drupal-Postgres-performance-by-using-pg_trgm.html">Improving Drupal Postgres Performance&lt;/a>&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>The instructions are a bit outdated so the updated syntax to enter in psql is given below:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>CREATE EXTENSION pg_trgm&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CREATE INDEX path_alias__alias_trgm_gist_idx ON path_alias USING gist &lt;span style="color:#ce5c00;font-weight:bold">(&lt;/span>&lt;span style="color:#204a87">alias&lt;/span> gist_trgm_ops&lt;span style="color:#ce5c00;font-weight:bold">)&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CREATE INDEX path_alias__path_trgm_gist_idx ON path_alias USING gist &lt;span style="color:#ce5c00;font-weight:bold">(&lt;/span>path gist_trgm_ops&lt;span style="color:#ce5c00;font-weight:bold">)&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ANALYZE path_alias&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;!-- Links Referenced --></description></item><item><title>Docs: Redis</title><link>https://drupalwxt.github.io/docs/development/performance/redis/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupalwxt.github.io/docs/development/performance/redis/</guid><description>
&lt;p>To properly configure Redis with Drupal you should ensure the following configuration is added to your &lt;code>settings.php&lt;/code> file.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note&lt;/strong>: Some customizations might be necessary depending on your individual requirements.&lt;/p>
&lt;/blockquote>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-php" data-lang="php">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">if&lt;/span> &lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">extension_loaded&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">))&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Set Redis as the default backend for any cache bin not otherwise specified.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;default&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.redis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;interface&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;PhpRedis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;scheme&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;http&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;host&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;localhost&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;port&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;6379&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;password&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">getenv&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;REDIS_PASSWORD&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">?:&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;redis.connection&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;persistent&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">FALSE&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Allow the services to work before the Redis module itself is enabled.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;container_yamls&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;modules/contrib/redis/example.services.yml&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;container_yamls&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;modules/contrib/redis/redis.services.yml&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Manually add the classloader path, this is required for the container cache bin definition below
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#8f5902;font-style:italic">// and allows to use it without the redis module being enabled.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$class_loader&lt;/span>&lt;span style="color:#ce5c00;font-weight:bold">-&amp;gt;&lt;/span>&lt;span style="color:#c4a000">addPsr4&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;Drupal\\redis\\&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;modules/contrib/redis/src&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">);&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;bootstrap_container_definition&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;parameters&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;services&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;redis.factory&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;class&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;Drupal\redis\ClientFactory&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.redis&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;class&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;Drupal\redis\Cache\CacheBackendFactory&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;arguments&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;@redis.factory&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;@cache_tags_provider.container&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;@serialization.phpserialize&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;cache.container&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;class&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;\Drupal\redis\Cache\PhpRedis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;factory&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;@cache.backend.redis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;get&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;arguments&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;container&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;cache_tags_provider.container&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;class&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;Drupal\redis\Cache\RedisCacheTagsChecksum&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;arguments&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;@redis.factory&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;serialization.phpserialize&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#39;class&amp;#39;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&amp;gt;&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;Drupal\Component\Serialization\PhpSerialize&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">];&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">/** Optional prefix for cache entries */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache_prefix&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;drupal_&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Always set the fast backend for bootstrap, discover and config, otherwise
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#8f5902;font-style:italic">// this gets lost when redis is enabled.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;bins&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;bootstrap&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.chainedfast&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;bins&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;discovery&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.chainedfast&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;bins&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;config&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.chainedfast&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Use for all bins otherwise specified.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;cache&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">][&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;default&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cache.backend.redis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Use for all queues unless otherwise specified for a specific queue.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#000">$settings&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;queue_default&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">]&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;queue.redis&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Or if you want to use reliable queue implementation.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#8f5902;font-style:italic">// $settings[&amp;#39;queue_default&amp;#39;] = &amp;#39;queue.redis_reliable&amp;#39;;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Use this to only use Redis for a specific queue.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#8f5902;font-style:italic">// $settings[&amp;#39;queue_service_aggregator_feeds&amp;#39;] = &amp;#39;queue.redis&amp;#39;;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">// Use this to use reliable queue implementation.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span> &lt;span style="color:#8f5902;font-style:italic">// $settings[&amp;#39;queue_service_aggregator_feeds&amp;#39;] = &amp;#39;queue.redis_reliable&amp;#39;;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">&lt;/span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Docs: Varnish</title><link>https://drupalwxt.github.io/docs/development/performance/varnish/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drupalwxt.github.io/docs/development/performance/varnish/</guid><description>
&lt;p>To properly configure Varnish with Drupal you should ensure the following configuration is your &lt;code>default.vcl&lt;/code> file.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note&lt;/strong>: Some customizations might be necessary depending on your individual requirements.&lt;/p>
&lt;/blockquote>
&lt;pre tabindex="0">&lt;code class="language-vcl" data-lang="vcl">vcl 4.0;
import std;
import directors;
backend nginx {
.host = &amp;#34;hostname-nginx&amp;#34;;
.host_header = &amp;#34;hostname-nginx&amp;#34;;
.port = &amp;#34;80&amp;#34;;
}
sub vcl_init {
new backends = directors.round_robin();
backends.add_backend(nginx);
}
sub vcl_recv {
set req.http.X-Forwarded-Host = req.http.Host;
if (!req.http.X-Forwarded-Proto) {
set req.http.X-Forwarded-Proto = &amp;#34;http&amp;#34;;
}
# Answer healthcheck
if (req.url == &amp;#34;/_healthcheck&amp;#34; || req.url == &amp;#34;/healthcheck.txt&amp;#34;) {
return (synth(700, &amp;#34;HEALTHCHECK&amp;#34;));
}
set req.backend_hint = backends.backend();
# Answer healthcheck
if (req.url == &amp;#34;/_healthcheck&amp;#34; || req.url == &amp;#34;/healthcheck.txt&amp;#34;) {
return (synth(700, &amp;#34;HEALTHCHECK&amp;#34;));
}
set req.backend_hint = backends.backend();
# Always cache certain file types
# Remove cookies that Drupal doesn&amp;#39;t care about
if (req.url ~ &amp;#34;(?i)\.(asc|dat|tgz|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$&amp;#34;) {
unset req.http.Cookie;
} else if (req.http.Cookie) {
set req.http.Cookie = &amp;#34;;&amp;#34; + req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, &amp;#34;; +&amp;#34;, &amp;#34;;&amp;#34;);
set req.http.Cookie = regsuball(req.http.Cookie, &amp;#34;;(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=&amp;#34;, &amp;#34;; \1=&amp;#34;);
set req.http.Cookie = regsuball(req.http.Cookie, &amp;#34;;[^ ][^;]*&amp;#34;, &amp;#34;&amp;#34;);
set req.http.Cookie = regsuball(req.http.Cookie, &amp;#34;^[; ]+|[; ]+$&amp;#34;, &amp;#34;&amp;#34;);
if (req.http.Cookie == &amp;#34;&amp;#34;) {
unset req.http.Cookie;
} else {
return (pass);
}
}
# If POST, PUT or DELETE, then don&amp;#39;t cache
if (req.method == &amp;#34;POST&amp;#34; || req.method == &amp;#34;PUT&amp;#34; || req.method == &amp;#34;DELETE&amp;#34;) {
return (pass);
}
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don&amp;#39;t need,
# rewriting the request, etc.
return (hash);
#return (pass);
}
sub vcl_backend_fetch {
# NEW
set bereq.http.Host = &amp;#34;hostname-nginx&amp;#34;;
# Don&amp;#39;t add 127.0.0.1 to X-Forwarded-For
set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, &amp;#34;(, )?127\.0\.0\.1$&amp;#34;, &amp;#34;&amp;#34;);
}
sub vcl_backend_response {
if (beresp.http.Location) {
set beresp.http.Location = regsub(
beresp.http.Location,
&amp;#34;^https?://[^/]+/&amp;#34;,
bereq.http.X-Forwarded-Proto + &amp;#34;://&amp;#34; + bereq.http.X-Forwarded-Host + &amp;#34;/&amp;#34;
);
}
# Only cache select response codes
if (beresp.status == 200 || beresp.status == 203 || beresp.status == 204 || beresp.status == 206 || beresp.status == 300 || beresp.status == 301 || beresp.status == 404 || beresp.status == 405 || beresp.status == 410 || beresp.status == 414 || beresp.status == 501) {
# Cache for 5 minutes
set beresp.ttl = 5m;
set beresp.grace = 12h;
set beresp.keep = 24h;
} else {
set beresp.ttl = 0s;
}
}
sub vcl_deliver {
# Remove identifying information
unset resp.http.Server;
unset resp.http.X-Powered-By;
unset resp.http.X-Varnish;
unset resp.http.Via;
# Comment these for easier Drupal cache tag debugging in development.
unset resp.http.Cache-Tags;
unset resp.http.X-Drupal-Cache-Contexts;
# Add Content-Security-Policy
# set resp.http.Content-Security-Policy = &amp;#34;default-src &amp;#39;self&amp;#39; *.example.ca *.example.ca; style-src &amp;#39;self&amp;#39; &amp;#39;unsafe-inline&amp;#39; *.example.ca https://fonts.googleapis.com; script-src &amp;#39;self&amp;#39; &amp;#39;unsafe-inline&amp;#39; &amp;#39;unsafe-eval&amp;#39; *.example.ca *.adobedtm.com use.fontawesome.com blob:; connect-src &amp;#39;self&amp;#39; *.example.ca *.omtrdc.net *.demdex.net *.everesttech.net; img-src &amp;#39;self&amp;#39; *.example.ca *.omtrdc.net *.demdex.net *.everesttech.net data:; font-src &amp;#39;self&amp;#39; *.example.ca https://fonts.gstatic.com&amp;#34;;
# Add CORS Headers
# if (req.http.Origin ~ &amp;#34;(?i)\.example\.ca$&amp;#34;) {
# if (req.url ~ &amp;#34;\.(ttd|woff|woff2)(\?.*)?$&amp;#34;) {
# set resp.http.Access-Control-Allow-Origin = &amp;#34;*&amp;#34;;
# set resp.http.Access-Control-Allow-Methods = &amp;#34;GET&amp;#34;;
# }
# }
# Add X-Frame-Options
if (req.url ~ &amp;#34;^/livechat&amp;#34; || req.url ~ &amp;#34;^/(en/|fr/)?entity-browser/&amp;#34;) {
set resp.http.X-Frame-Options = &amp;#34;SAMEORIGIN&amp;#34;;
} else {
set resp.http.X-Frame-Options = &amp;#34;DENY&amp;#34;;
}
set resp.http.X-Content-Type-Options = &amp;#34;nosniff&amp;#34;;
set resp.http.X-XSS-Protection = &amp;#34;1; mode=block&amp;#34;;
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
if (obj.hits &amp;gt; 0) {
set resp.http.X-Cache = &amp;#34;HIT&amp;#34;;
} else {
set resp.http.X-Cache = &amp;#34;MISS&amp;#34;;
}
# Handle errors
if ( (resp.status &amp;gt;= 500 &amp;amp;&amp;amp; resp.status &amp;lt;= 599)
|| resp.status == 400
|| resp.status == 401
|| resp.status == 403
|| resp.status == 404) {
return (synth(resp.status));
}
}
sub vcl_synth {
# Remove identifying information
unset resp.http.Server;
unset resp.http.X-Powered-By;
unset resp.http.X-Varnish;
unset resp.http.Via;
# Add Content-Security-Policy
# set resp.http.Content-Security-Policy = &amp;#34;default-src &amp;#39;self&amp;#39; *.example.ca; style-src &amp;#39;self&amp;#39; &amp;#39;unsafe-inline&amp;#39; *.example.ca; script-src &amp;#39;self&amp;#39; &amp;#39;unsafe-inline&amp;#39; &amp;#39;unsafe-eval&amp;#39; *.example.ca *.adobedtm.com use.fontawesome.com blob:; connect-src &amp;#39;self&amp;#39; *.example.ca *.omtrdc.net *.demdex.net *.everesttech.net; img-src &amp;#39;self&amp;#39; *.example.ca data:;&amp;#34;;
# set resp.http.X-Content-Type-Options = &amp;#34;nosniff&amp;#34;;
# set resp.http.X-Frame-Options = &amp;#34;DENY&amp;#34;;
# set resp.http.X-XSS-Protection = &amp;#34;1; mode=block&amp;#34;;
# if (resp.status &amp;gt;= 500 &amp;amp;&amp;amp; resp.status &amp;lt;= 599) {
# set resp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/503.html&amp;#34;));
# return (deliver);
# } elseif (resp.status == 400) { # 400 - Bad Request
# set resp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/400.html&amp;#34;));
# return (deliver);
# } elseif (resp.status == 401) { # 401 - Unauthorized
# set resp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/401.html&amp;#34;));
# return (deliver);
# } elseif (resp.status == 403) { # 403 - Forbidden
# set resp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/403.html&amp;#34;));
# return (deliver);
# } elseif (resp.status == 404) { # 404 - Not Found
# set resp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/404.html&amp;#34;));
# return (deliver);
# } else
if (resp.status == 700) { # Respond to healthcheck
set resp.status = 200;
set resp.http.Content-Type = &amp;#34;text/plain&amp;#34;;
synthetic ( {&amp;#34;OK&amp;#34;} );
return (deliver);
}
}
##
# ERROR HANDLING
##
# sub vcl_backend_error {
# set beresp.http.Content-Type = &amp;#34;text/html; charset=utf-8&amp;#34;;
# synthetic(std.fileread(&amp;#34;/data/configuration/varnish/errors/503.html&amp;#34;));
# return (deliver);
# }
&lt;/code>&lt;/pre></description></item></channel></rss>