Review 9.5 Merged

60656[BUGFIX] Support concurrent requests without 503 responses

Benjamin Franzke CR +2 V +2 Normal +70 −115 updated 05/06/19, 16:55

Commit message

Instead of offloading the work to wait for the final page content,
concurrent requests now wait for the real page content to be
rendered (and deliver the content from cache once ready) instead
of sending a 503 response code and the famous "Page is being
generated" message.

The logic to wait for the rendered page (lock and wait) is already
there thanks to the page locking, but was deliberately circumvented
by the temporary page cache content before to get rid of waiting
requests in high-load situations.

This approach to simply skip the temporary cache and wait for the
renderer to finish has been tested using the skip_page_is_being_generated
extension in wild for 3 years (for TYPO3 v6, v7, v8 and v9).

Note: In case the increased number of waiting requests has a negative
impact on sites with high server load, a additional proxy cache should be
considered in front of the server to make sure clients are served a valid
response without waiting until new content is ready.

The motivation for this change:
The 503 status code together with the "Page is being generated message"
does not only occur for slow or high traffic sites. It will be displayed
even for two concurrent requests, no matter how fast the page rendered
or how low the current traffic is.
The requests only need to (nearly) arrive at the same time. This can
easily be reproduced using two parallel curl requests:
for i in {1..2}; do curl -sv https://doma.in/foo |& grep '^< HTTP'& done
There would be one "503 Service unavailable" response when /foo has not
yet been rendered to the cache before.

An explanation for the releaseLock('pagesection') addition in
TSFE::getFromCache(): This has been added as the pagesection lock – which
is acquired in TemplateService::start() – was implicitly released in
setPageCacheContent() before. Now this would block concurrent rendering
for pages with $_GET-aware plugins, therefore we release the pagesection
lock early, after the pagesection cache has been generated.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Andreas Kienast +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Jonas Eberle +1
    • Andreas Kienast +1
    • TYPO3com +1 CI

Issues 1

Files 4

Review log 910

  1. Benjamin Franzke uploaded patch set 1 05/05/19, 19:25

  2. TYPO3com voted on patch set 1 V +1 05/05/19, 19:42 Completed build in 15m 59s on Sun, 5 May, 09:42 PM Test Summary: 50130 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC95-645

  3. Markus Klein commented on patch set 1 05/05/19, 20:41

    TypoScriptFrontendController.php:435

    we usually do not deprecated protected members, right?
  4. Benjamin Franzke commented on patch set 1 05/05/19, 20:57

    TypoScriptFrontendController.php:435 Reply

    Yes, but it was changed from public to protected in v9 development cycle (public being deprecated). That means it has been added to the deprecations guards (public function __isset, __get, __set) already and thus is "deprecated". Now that it's actually unusued (rather then internal) I think it's fine to mark this deprecated (as it's technically still public accessible in v9, therefore I didn't drop it). Has also been done for $activeUrlHandlers equally before.
  5. Markus Klein commented on patch set 1 05/05/19, 22:27

    TypoScriptFrontendController.php:435 Reply Unresolved

    Thanks for the explanation, I indeed overlooked that. To be really "strict" about this, we actually have a breaking change here. The content of the variable changes - better it does not change anymore. ;-)
  6. Benjamin Franzke voted on patch set 1 V +1 CR +1 05/06/19, 12:34

  7. Jonas Eberle commented on patch set 1 V +1 05/06/19, 13:53

    Checked with 20 concurrent requests, before and after applying patch, with a page with a userunc that sleeps 10s. Result with page already in cache or not is as expected: All requests finish simultaneously after being rendered/fetched from cache. All return with status 200 after applying the patch - before the patch the first one returns with 503.
  8. Andreas Kienast voted on patch set 1 V +1 CR +1 05/06/19, 13:55

  9. Benjamin Franzke voted on patch set 1 V +2 CR +2 05/06/19, 16:55

  10. Benjamin Franzke merged patch set 2 05/06/19, 16:55