New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cold caches can spawn many phpfpm processes on really large sites. #1398

Closed
peterbaker opened this Issue Apr 27, 2017 · 0 comments

Comments

Projects
None yet
3 participants
@peterbaker

peterbaker commented Apr 27, 2017

Expected behaviour

One would assume that if an HTML file has not been created for the static cache, and multiple visitors request it at the same time, a single child process would take place to create it, and tell the subsequent visitors to hang on a second until it's created.

Actual behaviour

Instead, it appears that any visitor requesting that URL at the same time spawns another phpfpm child process. It only takes 4 concurrent visitors to take down any Statamic site that hasn't created it's HTML cache file for that URL yet.

Steps to reproduce

Using bees with machine guns or any other load tester, on a single instance with multiple cores (load balancer or not), if the HTML cache page for any url hasn’t been created yet, throwing almost any number of visitors at the same time pegs all cpu cores at 100%, spawns a child phpfpm process for each visitor, and cripples the entire server.

If the HTML file was already there, everything is fine, but as it is right now, there’s nothing to stop Statamic from trying to create that HTML file for every single visitor that requests it until it is made (which becomes self defeating, as the more child processes, the less CPU there is to create it, and then we hid the max execution time no matter how many people are visiting).

Server Details

Operating System:
AWS, MacOS, Linux

Web Server:
Nginx, Apache

PHP Version:
5.5.9 / 7.0 / 7.1 (we've tested it on all of them)

Statamic Version:

2.5.8 / 2.5.9

Updated from an older Statamic or fresh install:

Updated.

@peterbaker peterbaker changed the title from Only 4 simultaneous visitors to an uncached site will take the server down. to Only 4 simultaneous visitors to an uncached site can take the server down. Apr 27, 2017

@peterbaker peterbaker changed the title from Only 4 simultaneous visitors to an uncached site can take the server down. to Cold caches can spawn many phpfpm processed on really large sites. Apr 27, 2017

@peterbaker peterbaker changed the title from Cold caches can spawn many phpfpm processed on really large sites. to Cold caches can spawn many phpfpm processes on really large sites. Apr 27, 2017

@jasonvarga jasonvarga closed this May 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment