Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!