Author Topic: DualImage.php script taking most of CPU time on server  (Read 380 times)

0 Members and 1 Guest are viewing this topic.

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
DualImage.php script taking most of CPU time on server
« on: July 23, 2020, 10:37:36 AM »
My site got slammed yesterday with a ton of severe weather around us.. One way, that's great.. Another.. it sucked up alot of CPU time on the servers and DualImage.php was the main culprit...

Is there anyway to get around this? Does someone have insight into this script?

Jim

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: DualImage.php script taking most of CPU time on server
« Reply #1 on: July 23, 2020, 10:38:53 AM »
can you post the script here?
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: DualImage.php script taking most of CPU time on server
« Reply #2 on: July 23, 2020, 10:52:35 AM »
Here....

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 836
  • #conligwx
    • conligwx.org
Re: DualImage.php script taking most of CPU time on server
« Reply #3 on: July 23, 2020, 11:17:54 AM »
there is a newer version from ken apparently.

https://saratoga-weather.org/DualImage.php?sce=view

dont think that will fix anything but worth updating anyway.

you'll need Ken to comment on the code and CPU resources of this script however
« Last Edit: July 23, 2020, 11:20:48 AM by ConligWX »
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: DualImage.php script taking most of CPU time on server
« Reply #4 on: July 23, 2020, 11:41:36 AM »
DualImage.php uses the GD library to construct a combination of two PNG images into one image for the 6hr primary forecasts for the 12hr period.  It usually completes in <100ms as the GD routines are quite fast for doing image merging.  Similar GD routines are used in the thermometer.php to construct the thermometer image with current/max/min displayed.

Since you're not running a Saratoga template, my usual diagnostics aren't available.
What is the server's operating system?  PHP version?  GD library version?

Lastly, how did you ascertain that DualImage.php was consuming the CPU time?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: DualImage.php script taking most of CPU time on server
« Reply #5 on: July 23, 2020, 11:51:48 AM »
Ken,
  I received a notification from ICDSoft regarding the usage of this one particular script.. Granted, my site was hit very heavily yesterday due to severe weather.

PHP version is 7.3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: DualImage.php script taking most of CPU time on server
« Reply #6 on: July 23, 2020, 12:01:38 PM »
That PHP version shouldn't be an issue.  If the NWS forecast calls for multiple dual image icons, your browser will cause a DualImage.php instance for each <img> needing generation.  Each instance should take about 100ms to execute and return an image to the browser.  The generated images are not cached on the server (too many variations would cause a large number of cache files).

If it happens again and you want to disable the DualImage capability, just uncomment the second line in this advforecast2.php code
Code: [Select]
$DualImageAvailable = file_exists("./DualImage.php") ? true : false;
// $DualImageAvailable = false;
so the $DualImageAvailable = false; is activated.  The advforecast2.php script will then use the first 6hr forecast for the period as the static image and DualImage.php will not be invoked.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: DualImage.php script taking most of CPU time on server
« Reply #7 on: July 23, 2020, 12:06:40 PM »
Thanks Ken... I will try that today...Expecting more severe weather later this afternoon so i should get a really good test in...

Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: DualImage.php script taking most of CPU time on server
« Reply #8 on: July 23, 2020, 12:18:15 PM »
If you have access to your access_log from yesterday, it would be interesting to analyze it for calls to DualImage.php to see the number of concurrent calls and where they were from..  I analyze all my sites daily with custom scripts looking for anomalies :)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: DualImage.php script taking most of CPU time on server
« Reply #9 on: July 23, 2020, 01:01:59 PM »
I think i have to turn that on manually but i will check with support to see if they can get their hands on yesterday's run.

 

anything