Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

401
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda