Website issues

Broken link? Feature request? Anything related to the Spectrum Computing website here.
Post Reply
User avatar
PeterJ
Site Admin
Posts: 6858
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Website issues

Post by PeterJ »

Hello,

I'm getting a lot of alerts over the last 24 hours from Digital Ocean that CPU usage is running high.

Sorry if things are running slow for anyone. We may eventually need to move to a larger virtual server. I will continue to monitor.

Peter
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: Website issues

Post by moroz1999 »

I can suggest doing some steps for this:
1. You can enable file cache for zxImage library, this will save a lot of CPU resources.
2. Profiling SQL requests to find the slowest ones and setting up appropriate indexes would help a lot.
3. You can also set up some data-caching for the heaviest SQL requests: if some popular SQL request cannot be improved further by indexes, you can serialize it and put it into file system (or Redis if it's available on your hosting) for some hours or even days.
4. You can cache the whole HTML responses, that would be the most efficient. Use output buffering to gather a response, make some hash from request uri and save the response with the name of this hash. Next time you get such request uri, just take an HTML from cache and serve it to user or invalidate the cache if it's too old.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Website issues

Post by Ast A. Moore »

Haven’t noticed any slowdown on my end. Granted, I rarely used the main site; mostly the forums.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: Website issues

Post by moroz1999 »

For the first suggestion:
$converter is an instance of ZxImage class.

Code: Select all

//make some folder for file cache
if (!is_dir($folderForCache)) {
	mkdir($folderForCache);
}
//set cache path to converter
$converter->setCachePath($folderForCache);
//enable file caching
$converter->setCacheEnabled(true);
After this all converted images would be automatically stored in the created folder by ZxImage converter. Same converter will also purge the cache automatically from time to time basing on cache file creation dates.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Website issues

Post by Einar Saukas »

moroz1999 wrote: Mon Dec 30, 2019 12:38 pm I can suggest doing some steps for this:
1. You can enable file cache for zxImage library, this will save a lot of CPU resources.
2. Profiling SQL requests to find the slowest ones and setting up appropriate indexes would help a lot.
3. You can also set up some data-caching for the heaviest SQL requests: if some popular SQL request cannot be improved further by indexes, you can serialize it and put it into file system (or Redis if it's available on your hosting) for some hours or even days.
4. You can cache the whole HTML responses, that would be the most efficient. Use output buffering to gather a response, make some hash from request uri and save the response with the name of this hash. Next time you get such request uri, just take an HTML from cache and serve it to user or invalidate the cache if it's too old.
If you can collect query statistics, I will gladly analyze and optimize them for you.

Although I agree that caching (options 1 and 4) are your best bet.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: Website issues

Post by moroz1999 »

I'm using all four suggestions in commercial projects, they are all helpful on their levels :)
User avatar
PeterJ
Site Admin
Posts: 6858
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Website issues

Post by PeterJ »

Thanks both, I will see what data I can get and will share it with you both.

Peter
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: Website issues

Post by RMartins »

Also check if the website machine, was not infected, with some kind of digital money harvesting bot.

It can also be someone exploring the system, like crawling the page and the search features to extract data.
Which is kind of dumb, since the data (ZX-DB) is open and free.
User avatar
moroz1999
Manic Miner
Posts: 329
Joined: Fri Mar 30, 2018 9:22 pm

Re: Website issues

Post by moroz1999 »

RMartins wrote: Tue Dec 31, 2019 1:34 am Also check if the website machine, was not infected, with some kind of digital money harvesting bot.
That's actually a nice advise. You can check it this way:
1. Download all files to separate directory
2. Compare it to repository using some bin comparison tool like windiff or beyond compare, this will show quickly any modifications in any scripts.

BTW, are you using 7.4 already? Each PHP update seems to have some real performance improvements in the core, and soon there would be a JIT available as well. You can also try to set up a script preloading list, this would help a lot as well.
But my guess is:
1. ZX images converter needs a file cache enabled, this one is CPU-demanding if done on a fly.
2. SQL requests indexes.
Post Reply