Performance Analysis and Optimization Based on CentOS servers

Source: Internet
Author: User
As a Linux system administrator, the most important task is to optimize system configuration so that applications can run in the optimal state on the system. However, hardware, software, and network environments are complex and changeable, as a result, the optimization of the system becomes abnormal and complex. How to locate the performance problem is a major problem in performance optimization. Starting from the system, this article focuses on the performance problems caused by improper system software and hardware configuration, and provides general methods and procedures for detecting system faults and optimizing performance. I. system performance analysis as a Linux system administrator, the main task is to optimize system configuration so that applications can run in the optimal state on the system, however, the complexity and variability of hardware problems, software problems, and network environments lead to abnormal and complex system optimization. How to locate the performance problems is a major challenge for performance optimization. Starting from the system, this article focuses on the performance problems caused by improper system software and hardware configuration, and provides general methods and procedures for detecting system faults and optimizing performance. I. Purpose of system performance analysis 1.1 locate the bottleneck of system performance the performance of the system refers to the effectiveness, stability, and response speed of the operating system to complete tasks. Linux system administrators may often encounter problems such as system instability and slow response speed. For example, if a Web Service is built on Linux, Web pages may often fail to be opened or opened slowly. When encountering these problems, some people will complain that the Linux system is not good. In fact, these are superficial phenomena. A task completed by the operating system is closely related to the system settings, network topology, routing devices, routing policies, access devices, physical lines, and other aspects, the performance of the entire system is affected when any problem occurs. Therefore, when a problem occurs in a Linux application, you should comprehensively check the application, operating system, server hardware, and network environment to locate the problem and then solve it in a centralized manner. 1.2 It is a complex and time-consuming process to provide performance optimization solutions to find system performance bottlenecks. You need to find and locate the bottlenecks in applications, operating systems, server hardware, and network environments, the biggest impact on performance is the application and the operating system, because the problems in these two aspects are hard to detect and the concealment is very strong. Hardware and network problems can be located immediately. Once the system performance problem is found, it is very fast and easy to solve. For example, if there is a problem with the system hardware, if it is a physical fault, you can replace the hardware, if the hardware performance cannot meet the requirements, you can upgrade the hardware. If you find a network problem, such as insufficient bandwidth or unstable network, you only need to optimize and upgrade the network; if it is an application problem, modify or optimize the software system. If it is an operating system configuration problem, modify the system parameters and system configuration. It can be seen that as long as the performance bottleneck is found, a performance optimization solution can be provided, with standard and purposeful system optimization. 1.3 balanced use of system hardware and software resources Linux is an open-source product and an open-source software practice and application platform supported by countless open-source software, common examples include Apache, Tomcat, MySQL, and PHP. The biggest idea of open-source software is freedom and openness. Linux, as an open-source platform, must realize the lowest cost through the support of these open-source software, to optimize application performance. However, the performance of the system is not isolated and solves a performance bottleneck, which may lead to another performance bottleneck. Therefore, the ultimate goal of performance optimization is: within a certain range, the use of various system resources tends to be reasonable and maintain a certain balance, that is, when the system runs well, it is precisely when the system resources reach a balance. In the operating system, excessive use of any resource will undermine this balance, resulting in slow system response or excessive load. For example, excessive use of CPU resources may lead to a large number of waiting processes in the system, resulting in slow application response, while a large increase in processes may lead to an increase in system memory resources, when the physical memory is exhausted, the system will use virtual memory, and the use of virtual memory will increase the disk I/O and increase the CPU overhead. Therefore, the optimization of system performance is to find a balance between hardware, operating systems, and application software.
Ii. Personnel involved in System Performance Analysis 2.1 Linux system administrators are responsible for important tasks during performance optimization. First, system Administrators should understand and master the current operating status of the operating system, such as system load, memory status, Process status, CPU load, and other information, this information is the basis and basis for detecting and judging system performance. Secondly, system administrators also have knowledge of the hardware information of the system, for example, disk I/O, CPU model, memory size, network card bandwidth, and other parameter information. Then, the system resource usage is evaluated based on the information. Third, as a system administrator, we also need to know the usage of system resources by applications. A more in-depth understanding of the running efficiency of applications, such as program bugs and memory overflow, by monitoring system resources, you can find out whether there is an exception in the application. If there is a problem in the application, you need to immediately report the problem to the program developers to improve or upgrade the program. Performance optimization is a complex and tedious process, system Administrators can optimize server performance only when they understand system hardware information, network information, operating system configuration information, and application information, this requires the system administrator to have sufficient theoretical knowledge, rich practical experience, and a thorough analysis of problems. 2.2 The second type of personnel involved in system performance optimization is the application architecture designer. After comprehensive judgment, the system administrator finds that the execution efficiency of the application affects the performance, the program architecture designer must promptly intervene to gain a deeper understanding of the running status of the program. First, the system architecture designer should track and understand the execution efficiency of the program. If there is a problem with the execution efficiency, find out where the problem occurs. Secondly, if the architecture design has a problem, we need to optimize or improve the system architecture and design a better application system architecture. 2.3 The final part of system performance optimization for software developers involves program developers. After the system administrator or architecture designer finds the program or structure bottleneck, program developers should immediately intervene in corresponding program modifications. To modify a program, the execution efficiency of the program should be taken as a benchmark, the logic of the program should be improved, and code optimization should be conducted in a targeted manner. For example, if the system administrator finds that an SQL statement consumes a lot of system resources and crawls the executed SQL statement, the system administrator finds that the execution efficiency of this SQL statement is too low, this is caused by low execution efficiency of Code Compiled by developers. Therefore, developers need to feedback this information to developers. After receiving this question, developers can perform targeted SQL optimization, to optimize the program code. From the above process, we can see that the general process for system performance optimization is: first, the system administrator can check the overall system status, the system hardware, network equipment, operating system configuration, application architecture, and program code are used to make a comprehensive judgment. If a problem occurs in system hardware, network equipment, or operating system configuration, the system administrator can resolve the issue based on the actual situation. If a program structure problem is found, it must be submitted to the program architecture designer. If a program code execution problem is found, it should be handed over to the developer for code optimization. This completes a process of system performance optimization.
Iii. Various factors affecting Linux performance 3.1 system hardware resources 1.CPU CPU is fundamental to the stable operation of the operating system. The CPU speed and performance largely determine the overall performance of the system, therefore, the more CPUs and the higher the clock speed, the better the server performance. But not exactly. At present, most CPUs can run only one thread at a time. hyper-threading processors can run multiple threads at a time. Therefore, the hyper-threading feature of the processor can be used to improve system performance. In a Linux system, hyper-threading is supported only when the SMP kernel is run. However, the more CPUs are installed, the fewer performance improvements are obtained from hyper-threading. In addition, the Linux kernel recognizes multi-core processors as multiple separate CPUs. For example, two 4-core CPUs are treated as eight single-core CPUs in the Lnux system. however, from the performance perspective, the two 4-core CPUs and eight single-core CPUs are not exactly equivalent. According to the test conclusion, the overall performance of the former is 25% ~ lower than that of the latter ~ 30%. applications that may encounter CPU bottlenecks include email servers and dynamic Web servers. For such applications, the CPU configuration and performance should be placed in the main position. 2. the memory size is also an important factor affecting Linux performance. The memory size is too small, system processes will be blocked, applications will become slow, and even the response will be lost. The memory size is too large, leading to a waste of resources. Linux uses two methods: physical memory and virtual memory. Although the virtual memory can alleviate the shortage of physical memory, it occupies too much virtual memory, and the performance of applications will be significantly reduced, to ensure high performance of applications, physical memory must be large enough. However, excessive physical memory may cause a waste of memory resources. For example, in a 32-bit processor Linux operating system, physical memory exceeding 8 GB will be wasted. Therefore, to use larger memory, we recommend that you install a 64-bit operating system and enable the Linux large memory kernel. Due to the limitation of the processor's addressing range, in a 32-bit Linux operating system, a single process of an application can only use 2 GB of memory, so that even if the system has a larger memory, applications cannot be used for "exclusive" purposes. The solution is to use a 64-bit processor to install a 64-bit operating system. In a 64-bit operating system, the memory usage requirements of all applications are almost unlimited. Applications that may encounter memory performance bottlenecks include printing servers, database servers, and static Web servers. For such applications, the memory size should be placed in the main position. 3. disk I/O performance disk I/O performance directly affects application performance. In an application with frequent read/write operations, if the disk I/O performance is not met, this will lead to application stagnation. Fortunately, today's disks use many methods to improve I/O performance, such as the common disk RAID technology.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.