Cs-Cart Is Consuming So Much Cpu Power

Wathcing the processes from shell with the top command I see that CPUb usage of php-cgi process by the CS-Cart user tops up arbitrarily to %80, %60, %45, %72.. and etc.

So that it slows down the cart. What could it be causing this consumption?

Wathcing the processes from shell with the top command I see that CPUb usage of php-cgi process by the CS-Cart user tops up arbitrarily to %80, %60, %45, %72.. and etc.

So that it slows down the cart. What could it be causing this consumption?

It deppends on the server specifications, OS, and the whole configuration of e.g. Apache, MySQL, php etc.

It deppends on the server specifications...

Of course it does. But how to diagnose? All the other sites on the same server are lighting fast; when it comes to CS-Cart, it has a delay about 2-3 seconds and by that time; it's using so much CPU.

Here are the server specs;

							CPU
						
							Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz (2 core(s))
					
							Version
						
							Plesk Onyx v17.0.17_build1700161028.14 os_CentOS 6
					
							OS
						
							CentOS 6.9 (Final)
					
							RAM
						
							4GB
					
	

Everything on the server is up to date by today.

Check the site with https://tools.pingdom.com/

You can turn on the debugger and look at the profile info that will tell you on a given page, where you're spending your time.

There are far too many variables to be able to give a simple answer. Imagery, hooked templates, addons, improper mysql configuration, etc. can all be factors.

Strongly suggested that cs-cart NOT be run on a shared server.

@martfox, I checked it using pingdom and saw that images are too much like 18Mb. I don't know how to descrase these; while it's a normal set of product images only. (There's only one banner being 1.1Mb, others are pretty well; but overall, it still has nothing to do with php-cgi consuming so much cpu, as images are all static.)

@tbirnseth, I use a VPS which serves about 20 domains and all the sites are pretty fast and very normal about the CPU usage. When it comes to CS-Cart-installed-domain, it uses approx. %50-80 CPU load only by visitng a page; and the generation of the page is slow in debugger mode. Page load time is slower because of the amount of the images; but the generation time (3 seconds) has nothing to do with the loading time. 3 seconds for the page generation is a serious problem I think.

Debugger tells me that some queries run multiple times like hell. There are 506 queries for the home page and for example;

			Query
		
			Count
		
			Min time
		
			Max time
		
			Average time
	
			SELECT destination_id, rate_value, rate_type FROM cscart_tax_rates WHERE tax_id = 6 AND destination_id = 1
		
			136
		
			0.00014
		
			0.00811
		
			0.00025
	
			SELECT tax_id, address_type, priority, price_includes_tax, regnumber FROM cscart_taxes WHERE tax_id IN (6) AND status = 'A' ORDER BY priority
		
			136
		
			0.00015
		
			0.05342
		
			0.00056
	

And memory usage is 12.5Mb, which I think is high too. If you want to check it out, here is the URL; https://elmacik.com

It seems like a server configuration issue. Check if these functions/modules are enabled:

mod_mpm_worker
mod_cgid
mod_deflate
mod_env
mod_expires
mod_headers
mod_proxy
mod_proxy_fcgi
mod_proxy_http
mod_suexec
mod_suphp
mod_unique_id

php56-php-fpm

It seems like a server configuration issue. Check if these functions/modules are enabled:

Hi martfox, I guess some of those extensions are not related to this issue; but nevertheless;

mod_mpm_worker (not compatible with Plesk?)
mod_cgid (installed)
mod_deflate (installed)
mod_env (installed)
mod_expires (installed)
mod_headers (installed)
mod_proxy (installed)
mod_proxy_fcgi (not present; instead mod_proxy_scgi is installed)
mod_proxy_http (installed)
mod_suexec (installed)
mod_suphp (not present and it has nothing to do with performance?)
mod_unique_id (installed)
php56-php-fpm (not present, due to absense of mod_mpm_worker)

I read articles pointing out that worker over prefork has issues with Apache. (and with Plesk, which I'm using). Because I will need to break so many configurations to get to install worker along with php-zts; which will conflict with my multi-version PHP configuration.

So if PHP-FPM will be better; why not using it natively with nginx? How can I switch CS-Cart to nginx?

Or how to specifically lower the repeated SQL queries?

All our servers use mod_mpm_worker and php56-php-fpm enabled and the CPU usage never goes over 5% and memory over 10%.

Not sure why, but it doesn't appear that things are not being cached in the browser. I.e. your css, images, etc. are being refetched for each page.

How much cpu you use is really irrelevant as long as it's under 100%. What's yours is yours on a VPS. Your TTFB is about 2.4secs from here (Portland Oregon) which is high. This is usually caused by DB accesses preparing data for pages.

It would take a detailed review and tools to determine exactly what are the contributing factors. After TTFB, your responses are quite good.

How many 3rd party addons do you have installed?

... CS-Cart user tops up arbitrarily to %80, %60, %45, %72.. and etc.

Yes, hard to say where the problem is. But generally, on a right configured server I will never allow such spikes over a time period like xy seconds/minutes.

...and of course - the initiator of the issue has to be fixed...

Thanks for the info guys.

I don't know why CSS and images would refetch everytime. There are only a few third party modules I'm using like;

-eComLabs Search Improvements
-Automatically calculate shipping rate
-XML Import
- AB: UniTheme (and some bundled with this one, like scroll to top button, deal of the day etc.)
I think CPU usage would be important because this happens even with one visitor on the page. So when I announce to have about 1k visitors a day; I think the CPU will burn.
TTFB must be high because of the repetitive queries I think. Because 506 queries for a loading a page is masssive. And all of it are repetitive. How could I decrease these?
Is it safe to use nginx at all and do you think after solving SQL query count issues, would nginx help increase performance? (Right now I'm using Apache for dynamic content and nginx for static.)

First, I would disable/uninstall all plug-ins and check the loading process. Then enable them back one by one and look which one is causing the high load.

OK I will try that.

And what about the image sizes? Right now the images on the homepage is approx. 15Mb and this is too much. When diagnosed, I see that thumbnails of the product images are approx. 100Kb; that's what I think it shouldn't be. I think it must have been at most ~30Kb.

Now trying to change thumbnail settings of CS-Cart, I see that I cannot upload any images, something must have been broken. New products never get images.

For optimizing your images you can try this tool. It works very well.

http://www.fookes.com/easy-thumbnails

If the dimensions of your imagery is producing too large an image size then you have no choice but to reduce the quality. Your settings should never be more than 80% on a thumbnail and you must ensure that whatever you're doing to load those images that they are being translated into the appropriate thumbnail size versus simply referencing the image and giving it a widht/height. If these images are being handled completely by the cs-cart tools then they will be sized appropriately. But if you've built this template and simply reference the detailed image, then the whole image will be sent to your browser and it will then reduce it to size. The goal is to send the imagespre- sized appropriately to the browser.

Update: I solved the imaging issues by changing thumbnail type to JPEG and descreasing the quality to 60%. This way, 100KB files fell to around 5-10KB; and I lowered the product count in the blocks. I also disabled HiDPI extension (which was creating too small dimensioned but very high sized thumbnails). Now homepage fell to 2.4Mb from 18.5Mb; it loads faster now; while two problems remain;

1- It still consumes so much CPU power.

2- (I think accordingly) TTFB is still so high. It looks like it waits about 2-3 seconds and loads everything at once.

I copied the site completely to a new domain to test switching to nginx with PHP-FPM; it's a little faster but these two problems are still there; this time it's just php-fpm took place of php-cgi. (Means this time php-fpm is consuming nearly 100% CPU power everytime I click something on the web site. It sometimes shows even higher like 150% ??)

Edit: Forgot to say that disabling third party addons didn't really effect aynthing.

Note that on first load those thumbnails will need to be dynamically created and will suck up a lot of cpu. Make sure all your file/directory permissions are set properly for your images/thumbnails and all the subfolders.

Note that on first load those thumbnails will need to be dynamically created and will suck up a lot of cpu. Make sure all your file/directory permissions are set properly for your images/thumbnails and all the subfolders.

Yes I'm aware. That's why I check it by surfing a lot around to see the difference; but everytime it's the same. Just the ratio of the CPU usage is changing %50, %90, %70 and so on..

Permissions are all set properly; I also overrided just in case.

Yes I'm aware. That's why I check it by surfing a lot around to see the difference; but everytime it's the same. Just the ratio of the CPU usage is changing %50, %90, %70 and so on..

Permissions are all set properly; I also overrided just in case.

I sent you a PM.