Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

394
Visualizações
How to reduce CPU Usage when using Chrome Headless

I've built an API using Laravel with a centos installed server.

In the API, there is a process that uses headless chrome like this to get an HTML source.

[MyController.php]

$url = $request['url'];
$browser = $browserFactory->createBrowser(
    [
        'headless' => true,
        'noSandbox' => true,
    ]
);

try{
    $this->page = $browser->createPage();
    $this->page->navigate($url)->waitForNavigation(Page::LOAD, 60);
    $response = $this->page->evaluate('document.documentElement.outerHTML')->getReturnValue();
    $resolvedURL = $this->page->getCurrentUrl();
    // too long to load
} catch (OperationTimedOut $e) {
    $response  = null;
    $resolvedURL = null;
    // An other page was loaded
} catch (NavigationExpired $e) {
    $response  = null;
    $resolvedURL = null;
} finally {
    $browser->close();
}

// analyze retrived html code
.
.
.

Now, my server has a high load average problem due to high CPU Usage and I tried to figure out the reasons why.

I have many HTTP requests to this API obviously as you can see many PHP-fpm processes are running on the screenshot.

I'd like to lower the load average on the server without regulating the number of PHP-fpm max children, but I'm not really good at server managing.

To lower the CPU Usage, what I can do? I did my best to optimize my PHP code already.

Like is it possible to share one Chrome process in all PHP-fpm processes so that I don't have to create a chrome process for each HTTP request?

enter image description here

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda