BBlack has submitted this change and it was merged.

Change subject: Set up /api/rest_v1/ entry point for restbase
......................................................................


Set up /api/rest_v1/ entry point for restbase

There are major performance benefits in minimizing the number of domains we
use to serve content. As documented in T95229, total cold-start overheads for
a new domain (DNS, TCP & TLS) seem to exceed 1s with mean VE user's connection
latencies.

This patch sets up a path-based entry point for the REST API at /api/rest_v1/,
which avoids this issue by sharing the existing connection(s) to the main
project domain. Requests matching ^/api/rest_v1/ are diverted to the restbase
cluster in the backend Varnishes. While there might be performance advantages
in doing this in the frontend Varnish (especially for esams, where we'd reduce
the number of Varnish hops from 3 to 1), other considerations like IPSec make
traversing the second layer more practical for now.

Additional minor tweaks:

- Configure beta labs restbase instance

Bug: T95229

Change-Id: I46e422825af2cf6f972b64e6d50040220ab08995
---
M modules/role/manifests/cache/configuration.pp
M modules/role/manifests/cache/text.pp
M templates/varnish/text-backend.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
4 files changed, 22 insertions(+), 0 deletions(-)

Approvals:
  BBlack: Looks good to me, approved
  GWicke: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/modules/role/manifests/cache/configuration.pp 
b/modules/role/manifests/cache/configuration.pp
index 6cdae9b..49e8b2d 100644
--- a/modules/role/manifests/cache/configuration.pp
+++ b/modules/role/manifests/cache/configuration.pp
@@ -71,6 +71,9 @@
             'citoid' => {
                 'eqiad' => 'citoid.wmflabs.org',
             },
+            'restbase' => {
+                'eqiad' => 'deployment-restbase01.eqiad.wmflabs',
+            },
         }
     }
 }
diff --git a/modules/role/manifests/cache/text.pp 
b/modules/role/manifests/cache/text.pp
index 25743dd..e65c0fa 100644
--- a/modules/role/manifests/cache/text.pp
+++ b/modules/role/manifests/cache/text.pp
@@ -30,6 +30,7 @@
             'api'               => 
$role::cache::configuration::backends[$::realm]['api'][$::mw_primary],
             'rendering'         => 
$role::cache::configuration::backends[$::realm]['rendering'][$::mw_primary],
             'test_wikipedia'    => 
$role::cache::configuration::backends[$::realm]['test_appservers'][$::mw_primary],
+            'restbase'          => 
$role::cache::configuration::backends[$::realm]['restbase'][$::mw_primary],
         },
         'two' => {
             'eqiad' => $text_nodes['eqiad'],
@@ -81,6 +82,11 @@
                 'max_connections' => 20,
             },
             {
+                'backend_match'   => '^restbase\.svc\.|^deployment-restbase',
+                'port'            => 7231,
+                'max_connections' => 5000,
+            },
+            {
                 'port'                  => 80,
                 'connect_timeout'       => '5s',
                 'first_byte_timeout'    => '180s',
diff --git a/templates/varnish/text-backend.inc.vcl.erb 
b/templates/varnish/text-backend.inc.vcl.erb
index 62d6571..a697af4 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -38,6 +38,17 @@
        }
 <% end -%>
 
+       if (req.url ~ "^/api/rest_v1/") {
+<% if @vcl_config.fetch("cluster_tier", "one") == "one" -%>
+               set req.url = "/" + req.http.host + regsub(req.url, 
"^/api/rest_v1/", "/v1/");
+               set req.backend = restbase;
+<% else -%>
+               set req.backend = <%= @vcl_config.fetch("default_backend", 
"backend") %>_random;
+<% end -%>
+               set req.hash_ignore_busy = true;
+               return (pass);
+       }
+
        if (req.url ~ "^/wiki/Special:CentralAutoLogin/") {
 <% if @vcl_config.fetch("cluster_tier", "one") != "one" -%>
                set req.backend = <%= @vcl_config.fetch("default_backend", 
"backend") %>_random;
diff --git a/templates/varnish/text-frontend.inc.vcl.erb 
b/templates/varnish/text-frontend.inc.vcl.erb
index 63afd11..689ec15 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -100,6 +100,8 @@
        if (req.url ~ "^/wiki/Special:CentralAutoLogin/") {
                set req.backend = backend_random;
                set req.hash_ignore_busy = true;
+       } else if (req.url ~ "^/api/rest_v1/") {
+               set req.backend = backend_random;
        }
 
        if (req.request != "GET" && req.request != "HEAD") {

-- 
To view, visit https://gerrit.wikimedia.org/r/203871
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I46e422825af2cf6f972b64e6d50040220ab08995
Gerrit-PatchSet: 20
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: BBlack <bbl...@wikimedia.org>
Gerrit-Reviewer: CSteipp <cste...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to