Bug #87980

TYPO3 can not handle two concurrent requests to the same (cachable) page without a 503 response

Added by Benjamin Franzke 2 months ago. Updated 18 days ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Start date:
2019-03-22
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If two concurrent requests try to access a page, a 503 response code (together with the famous "Page is being generated" message) is returned, no matter how fast/slow the pages are rendered or whether there is low/high traffic.

A 503 HTTP response code should only be sent due to high server overload, not because of two simple requests.

This issue can be verified by running two curl requests to the same url in parallel:

url=https://mytypo3site.com/foo
for i in {1..2}; do curl -sv $url |& grep '^< HTTP'& done

This would return:
< HTTP/1.1 503 Service unavailable
< HTTP/1.1 200 OK

It should return:
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK

Currently this can be fixed using the https://extensions.typo3.org/extension/skip_page_is_being_generated/ extension, but it would be desirable if TYPO3 core could fix it.


Related issues

Related to TYPO3 Core - Bug #88250: Remove temporary page cache entry (aka page is being generated message) Closed 2019-04-30
Related to TYPO3 Core - Task #77443: Make "Page is being generated" configurable Closed 2016-08-08

Associated revisions

Revision 45501703 (diff)
Added by Benjamin Franzke 19 days ago

[BUGFIX] Support concurrent requests without 503 responses

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.

Releases: master, 9.5, 8.7
Resolves: #87980
Change-Id: I034f410335b3035c5863b26e3e689ca29b5f3f80
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307
Tested-by: TYPO3com <>
Tested-by: Oliver Hader <>
Tested-by: Helmut Hummel <>
Tested-by: Benjamin Franzke <>
Reviewed-by: Georg Ringer <>
Reviewed-by: Oliver Hader <>
Reviewed-by: Helmut Hummel <>
Reviewed-by: Markus Klein <>
Reviewed-by: Benni Mack <>
Reviewed-by: Benjamin Franzke <>

Revision b8775ca3 (diff)
Added by Benjamin Franzke 19 days ago

[BUGFIX] Support concurrent requests without 503 responses

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.

Releases: master, 9.5, 8.7
Resolves: #87980
Change-Id: I034f410335b3035c5863b26e3e689ca29b5f3f80
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60656
Tested-by: TYPO3com <>
Tested-by: Jonas Eberle <>
Tested-by: Andreas Fernandez <>
Tested-by: Benjamin Franzke <>
Reviewed-by: Andreas Fernandez <>
Reviewed-by: Benjamin Franzke <>

Revision b78d6af2 (diff)
Added by Benjamin Franzke 19 days ago

[BUGFIX] Support concurrent requests without 503 responses

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.

Releases: master, 9.5, 8.7
Resolves: #87980
Change-Id: I034f410335b3035c5863b26e3e689ca29b5f3f80
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60660
Tested-by: TYPO3com <>
Tested-by: Jonas Eberle <>
Tested-by: Andreas Fernandez <>
Tested-by: Benjamin Franzke <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Andreas Fernandez <>
Reviewed-by: Benjamin Franzke <>

History

#1 Updated by Gerrit Code Review 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#2 Updated by Gerrit Code Review 2 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#3 Updated by Jonas Eberle about 2 months ago

Running more requests in parallel yields

< HTTP/1.1 503 Service unavailable
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK

That is really weird behaviour and surely not intentional. The suggested patch fixes that.

#4 Updated by Helmut Hummel 25 days ago

  • Related to Bug #88250: Remove temporary page cache entry (aka page is being generated message) added

#5 Updated by Gerrit Code Review 24 days ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#6 Updated by Gerrit Code Review 22 days ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#7 Updated by Gerrit Code Review 20 days ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#8 Updated by Gerrit Code Review 20 days ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60307

#9 Updated by Gerrit Code Review 20 days ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60656

#10 Updated by Gerrit Code Review 19 days ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60660

#11 Updated by Benjamin Franzke 19 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#12 Updated by Benni Mack 18 days ago

  • Status changed from Resolved to Closed

#13 Updated by Markus Klein 16 days ago

  • Related to Task #77443: Make "Page is being generated" configurable added

Also available in: Atom PDF