Page MenuHomePhabricator

Separate Traffic layer caches for PHP7/HHVM
Closed, ResolvedPublic

Description

Since we're still in an early testing phase of PHP7 for serving our user traffic, so we want to avoid "poisoning" the cache objects everyone sees with pages possibly badly rendered from a PHP7 beta feature user.

In order to do this, we will need to:

  • Separate caches on the value of the X-Seven request header, set for requests with the PHP_ENGINE cookie set to php7
  • For a request with no specific cookie, present the cached content for the same default engine as the backend (now HHVM, later, PHP7)
  • For a request with the specific cookie, present the corresponding cached content

Event Timeline

Strawperson proposal from IRC, in pseudocode for cache_text, assuming the magic cookie is f2b31d03ab7:

sub recv_from_client_at_front_edge() {
    unset req.http.x-use-engine;
    if req.http.Cookie ~ "f2b31d03ab7" {
        set req.http.x-use-engine = "php7";
    } else {
        set req.http.x-use-engine = "hhvm";
    }
}

sub recv_response_headers_from_mediawiki() {
    resp.http.Vary += "x-use-engine";
}
ema triaged this task as Medium priority.Oct 11 2018, 9:43 AM

From IRC for posterity:

17:01 < bblack> the straw pseudo-code still seems like a legit approach to me, but in practice there's some rough edges to it.  chiefly, that cross my mind immediately:
17:02 < bblack> 1) Integrating it properly with the Cookie vs X-Orig-Cookie or whatever we do for general cookie-hacking on cache_text (it may be we need to look at 
                X-Orig-Cookie, depending on where this is all injected at)
17:03 < bblack> 2) We probably want to handle the Vary modification with more grace, as the approach there will effectively invalidate all cache contents on deploy.  
                Probably the right answer is to only use the special header (x-use-engine) for the minority (php7) case.

We should get this all design-validated/written/tested/deployed by ~ first week of December so as not to hold up the appserver side of things!

Change 478680 had a related patch set uploaded (by BBlack; owner: BBlack):
[operations/puppet@production] cache_text: Vary for PHP7

https://gerrit.wikimedia.org/r/478680

Change 478680 merged by BBlack:
[operations/puppet@production] cache_text: Vary for PHP7

https://gerrit.wikimedia.org/r/478680

akosiaris claimed this task.
akosiaris subscribed.

I think we can resolve this, right? I am gonna be bold and resolve it, feel free to reopen if needed

Change 525274 had a related patch set uploaded (by Ema; owner: Ema):
[operations/puppet@production] WIP: ATS: Vary-slotting for PHP7

https://gerrit.wikimedia.org/r/525274

Change 525274 merged by Ema:
[operations/puppet@production] ATS: Vary-slotting for PHP7

https://gerrit.wikimedia.org/r/525274

Just a heads up, we are planning to start migrating API servers to serve only via PHP7. For the time being, we have one in each DC.