IMCAFS

Home

5 boards to improve website performance

Posted by millikan at 2020-02-23
all

Apache is still the most widely used web server in the Internet connected websites and computers.

In addition, Apache continues to grow the most among major web servers, followed by nginx and IIS. So if you're the administrator of the Apache system, you need to know, How to ensure that the maximum performance of your web server meets your needs)(

In this article, we'll discuss some suggestions that will help you ensure the continuity of Apache's work and enable you to handle the number of requests expected from remote clients.

Remember, however, that Apache is not designed to install test records - but nonetheless, In fact, it can still guarantee high performance for any use you can think of.

Council 1: always update Apache to the latest version

Of course, installing the latest version of Apache may be the first thing you need to consider.

However, it may be a recent improvement or correction, which is added to the recently released stable version and can then be downloaded and installed From source code. There are also instructions for compiling and installing - remember, if you choose this update method, You can back up your current profile / website / virtual host as a precaution.

In any case, you can check the version installed so far as follows:

Recommendation 2: if you use a core above 2.4, consider updating

Why? The version of sendfile called in kernel 2.4 and above is the default. This, in turn, Convenient and efficient network file transfer( Use less CPU to read and send at the same time.

You can view the core of your installation in the following ways:

# uname -r

And put it with the most stable core at www.kernel.org.

Recommendation 3: choose a multiprocessing module) MPM, which is the most suitable situation for you.

In fact, MPM enhances Apache's modularity, allowing you to decide how to configure a car with a web server connected to a network port, Accept customer requests and use subroutines) and flows (another way) to process them.

From version 2.4, Apache offers three different MPM options depending on your needs:

Check the MPM used by your Apache device, what you can do:

The following image shows this particular web server using prefork MPM.

To change this, you need to edit:

In MPM, it can be MPM u event, MPM. U

LoadModule mpm_event_module modules/mod_mpm_event.so

Explain You may need to install libpache 2-mod-fastcgi from a paid repository.

In addition, for the center, you'll need PHP FPM) with fcgi and mod \ u fcgid, while in Debian, it's called PHP5 FPM) with Apache 2-mpm-event.

Last but not least: restart the web server and the recently installed PHP FPM service) or PHP5 FPM:

RedHat Center
Debian/Ubuntu
# systemctl restart apache2 php5-fpm & systemctl enable apache2 php5-fpm

Although you can configure Apache to use a specific MPM, this configuration can be redefined for each virtual host as shown above.

Simply place the appropriate label in the configuration file for each virtual host, and you're ready to work, but make sure you only use one MPM to the virtual host.

Finally, note that regardless of the distribution you choose, PHP FPM depends on the implementation of fastcgi, so I recommend installing more packages before. For more details and examples of PHP FPM, and how MPM events can improve Apache performance, see the official documentation.

This is what I see. When I change the default situation of MPM, events in the same window, in the previous image:

For example:

The reason why I raise this question is that I have recently encountered a problem, When firewalld configuration is set in cloud VPS, PHP FPM and Apache are not allowed to process PHP file by default.

As a basic test), I believe you can consider more complex or stress, and I will create a PHP file. Check if there is another file named test.php in the same folder with two hostnames called cenos 7 that have the same device and download performance, but with other MPMS. One will use events, and the other will use prefork:

This is the PHP code I saved in a file named checkifilexists.php:

?php $filename = 'test.php'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?

Then we run an Apache test tool (AB) from 200 simultaneous requests to 2000 requests:

# ab -k -c 100 -n 2000 localhost/checkiffileexists.php

Let's start the test and compare the results. Please note the performance statistics:

As you can see, the performance of the server greatly exceeds that of its simulated prefork test in all aspects.

Recommendation 4. Allocate memory properly for Apache

Perhaps the most important hardware element to consider is the number of ODS allocated to each Apache process. Although you can't control it directly, you can limit the number of subroutines through maxrequestworkers (formerly known as maxclients Apache 2.2) Restrict the use of Apache restrictions. Again, you can set this value for each host or virtual host.

To do this, you have to pay attention to the average amount of memory used by Apache, and then multiply that by maxrequestworkers, which is the amount of memory, Select for the Apache program. One thing you never want your web server to start using swap is that it can dramatically degrade its performance. Therefore, you must always keep Apache's memory within your reach, independent of swap.

For example, the next group will limit the processing of 30 customers at the same time. If more customers enter the host, they may encounter delay or short-term failure, which is easily solved by updating the browser. While this may be considered unwelcome, it's useful for servers and, ultimately, for your site.

Please note that the same principles apply to all MPM events that I use here to continue the concept proposed by the previous Council:

IfModule mpm_event_module StartServers 3 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxRequestWorkers 30 MaxConnectionsPerChild 1000 /IfModule

In any case, it is highly recommended that you contact the Apache 2.4 file to see what directives allow you to select MPM.

Recommendation 5. Learn about your app

Generally, you should not load any Apache modules, which is not strictly necessary for your application. This will require at least general knowledge of the applications running on your server, especially if you are a system administrator and another team responsible for development.

You can list the currently loaded plug-ins:

On the other hand, Debian provides a tool called a2dismod disable module, which is used as follows:

# a2dismod module_name

Let him come back:

# a2enmod module_name

In any case, don't forget to restart Apache for the changes to take effect.

Thank you for taking the time to read this article!

If you have any questions, please mention them in the comments.

Subscribe to our blog updates and keep the news of the world in communication!

In order to learn more and more about the information and communication technology population, write Cisco courses, network security courses, and complete network security courses, (DEVNET course) (programmable network) otakademi Cisco, sedicomm University, Linux professional institution platform).

Cisco and Linux jobs!

Apply quickly! There are several seats. The groups began their work on 22 July and 19 August, 23 September, 21 October, 25 November, 16 December, 20 January and 24 February, respectively.

What will you get?

How is your study?

We can also help you:

Study in Cisco CCNA Routing & Switching and Linux LPI courses, apply for or consult for free.