Knowledgebase

How to reduce CPU/Memory consumption on a website?

In many cases there have been problems or confusion regarding this topic among our web hosting, for which I was asked to explain how it works, best of all, how to resolve this issue with sites in PHP, prepare the pencil and paper that we are going to start.< br />
First of all, I announce that this is a rather broad topic, and that will try to explain it as clearly and concisely as possible, so that if you are looking for something specific you can simply use this mini-index:

1: What are the consumptions about?
2: Why do you get to the suspension point?
3 : Ok, but let's go to How to solve it?
- 3.1: A high volume of visits per day with Pre-Armed Scripts
- 3.2: A high volume of visits per day with Proprietary Scripts
- 3.3: Very high consumption and average or low visits
- 3.4: None of the previous ones



1.- What are the consumptions about?

To start with, as (perhaps not everyone) knows, computers and servers work in a very similar way; For each process, the CPU is essentially used to interpret the code and the RAM memory is used to store the data while it is executed. It's right there with all the websites.

In the case of HTML sites, the process is practically null and it can be decided that upon entering the website the page is automatically downloaded and shown to the user. On sites with web programming (PHP, Perl or others), the CPU must first process your code to be able to show the page to the user.


2.- Why do you get to the suspension point? inefficient data collection, or poor administration of databases/content archives; We can cause the site to consume a lot of memory, which leads to a loop (endless repetition cycle), which ends up working on the entire PC or the entire Server, depending on the case.

This is the reason why access to these sites that cause malfunctions or conflicts is stopped, and you should notify yourself appropriately with a notice to the owner (the domain reseller). Possibly if there is a reason why you are reading this, let's hope it doesn't happen.

If this is not stopped, the server would continue to load exponentially until the point was completely inaccessible even for an administrator. Don't say that anyone wants to see your web page crashed by something that someone else doesn't know or have a relationship with.

 

3.- Ok, but let's go to How to solve it?

Impatient or no, lo What matters is to avoid this type of problem, so divide the possible reasons between 4 groups, review the first rules of each to know which one applies to you.


- CASE 1: A high volume of visits per day with Pre-Armed Scripts

Let's take as a reference more than 2000 or 3000 unique visits per day (unique visits are counted once for each IP), although this is not a very high number, it depends on the time at which all visits are produced, given that if 80% of visits are produced 14 to 16 hours, possibly at these times your site overloads the server and needs to be corrected, but for the rest of the day there won't be many visits.

If you pose a CMS</em > pre-armed (e.g. PHP-Nuke, PostNuke, Joomla!, Mambo, among others), or some advanced script as a forum (e.g. vBulletin, IPB, phpBB), a blog (Wordpress, b2evolution, others), the similar, it's more likely that it requires a more robust system configuration and you need to think about going to a better plan (if you don't already have it), how to be a Virtual Server (VPS) or Dedicated Server, depending on the volume of visits.

The only alternative would be to turn off the system you use and program it on your own, easier and more basic than the previous one, but allowing the system to require less CPU to process it despite the low number of visits ( Returning to the previous topic, HTML does not require any process, compared to PHP+MySQL which can cause problems with such visitor levels).

Please note that if you pose many plugins / addons in these scripts, It also increases the level of consumption that is generated, so it is very important to remove unnecessary modules or scripts to debug and prevent the CPU from escaping to places that are of no use to us.

It is also important that your scripts and addons/plugins

  • 20 Users Found This Useful
Was this answer helpful?

Related Articles

For Joomla 1.5 optimization

Joomla uses a configuration to optimize your website, this is in the "Global Configuration"...

For Joomla 1.0.x optimization

These are some tips on how to improve the performance of your Joomla 1.0.x website:* Enable cache...

For Moodle Cache optimization

To optimize Moodle, it is working from version 1.7 or earlier.We can configure the Cache Type on...

For Drupal optimization

There is an option in the drupal panel, which is called Performance and is found in the...

For Wordpress Cache optimization

WP SUPER CACHE a brief description of this plugin.This plugin, as you can see in the attached...