How many questions can you answer about Linux? --Answer 21-25 questions

Source: Internet
Author: User
Tags disk usage

21. How to optimize the performance, how to increase the boot speed?

21.1 Performance optimization is definitely a very big problem, there are too many places to affect performance, refer to the following topics:

http://www.it168.com/redian/linuxmr/

If the interviewer asks you for ideas, you can refer to:

First, what is the purpose of optimization? Or, what is the optimization indicator?

(Refer to http://blog.chinaunix.net/uid-7177878-id-252142.html)

(1) Processor parameters

This is a very simple parameter that visually describes the utilization of each CPU. In the xseries architecture, a processor bottleneck can occur if the CPU is more than 80% utilized for a prolonged period of time.

Runable processes
This value describes the process being prepared to be executed, which should not exceed 10 times times the number of physical CPUs in a single duration, otherwise there may be bottlenecks in the CPU.

Blocked
Describes the processes that cannot be executed because of waiting for the I/O operation to end, blocked may indicate that you are facing an I/O bottleneck.

User time
Describes the percentage of user processes that are processed, including nice time. If the value of user time is high, the system performance is used to handle the actual work.

System time
Describes the percentage of CPU spent on processing kernel operations, including IRQ and software interrupts. If system time is high, there may be a network or drive stack bottleneck. A system typically spends little time dealing with kernel operations.

Idle time
Describes the percentage of CPU idle.

Nice time
Describes the percentage of the CPU that is spent processing the re-nicing process.

Context switch
The number of interchanges between threads in the system.

Waiting
The total time that the CPU spends waiting for I/O operations, similar to blocked, is that a system should not spend too much time waiting for I/O operations, or you should further detect if the I/O subsystem has bottlenecks.

Interrupts
Interrupts values include hard interrupts and soft interrupts, and hard interrupts can have more adverse effects on system performance. The high interrupts value indicates that the system may have a bottleneck in the software, either the kernel or the driver. Note that the interrupts value includes interrupts caused by the CPU clock (the modern xserver system has a value of 1000 interrupts per second).

(2) Memory parameters

Free memory
Compared to other operating systems, the value of Linux free memory should not be an important indicator of a performance reference because, as we mentioned earlier, the Linux kernel allocates a large amount of unused memory as the filesystem cache, so this value is usually small.

Swap usage
This value describes the swap space that has been used. Swap usage only represents the validity of Linux managed memory. The swap in/out is a more meaningful basis for identifying memory bottlenecks, and if the value of the swap in/out remains at 200 to 300 pages per second, it usually indicates a potential memory bottleneck for the system.

Buffer and Cache
This value describes the cache allocated for the file system and the block device. Note in red Hat Enterprise Linux 3 and earlier versions, most of the free memory is allocated as a cache usage. In the later versions of Red Hat Enterprise Linux 4, you can adjust the amount of free memory as a cache by modifying the page_cache_tuning in/PROC/SYS/VM.

Slabs
Describes the memory space used by the kernel, noting that the kernel's pages cannot be swapped to disk.

Active versus inactive memory
Provides active memory information about system memory, inactive memory is the space that is swapped by the KSWAPD daemon to disk.

(3) Network parameters

Packets received and sent
This parameter represents the number of packets received and sent by a specified network card.

Bytes received and sent
This parameter represents the number of bytes of packets received and sent by a specified network card.

Collisions per second
This value provides the number of network conflicts that occur on the specified network card. The persistent presence of this value represents a bottleneck in the network architecture, not a problem on the server side. Conflicts in a normally configured network are rare unless the user's network environment is composed of a hub.

Packets dropped
This value indicates the number of packets discarded by the kernel, possibly due to a lack of firewalls or network caches.

Overruns
Overruns expresses the number of times the network interface cache is exceeded, and this parameter should be linked to the packets dropped value to determine if there is a bottleneck in the network cache or the network queue is too long.

Errors
This value records the number of frames that are flagged as failed. This may be caused by the wrong network configuration or some network cable damage, the damage of some network cables in the copper port Gigabit Ethernet environment is an important factor affecting the performance.

(4) Block device parameters

Iowait
The time that the CPU spends waiting for I/O operations. This consistently high value can often be caused by an I/O bottleneck.

Average Queue Length
The number of I/O requests, typically a disk queue value of 2 to 3 is the best case, and a higher value indicates that the system may have an I/O bottleneck.

Average wait
The average time to respond to an I/O operation. Average wait includes the time of the actual I/O operation and the time waiting in the I/O queue.

Transfers per second
Describes how many I/O operations (including read and write) are performed per second. The value of transfers per second, combined with Kbytes per second, can help you estimate the average transmission block size of the system, which typically matches the stripe size of the disk subsystem to achieve the best performance.

Blocks Read/write per second
This value expresses the number of blocks read/write per second, which is 1024bytes in the 2.6 kernel, and blocks can be different sizes from 512bytes to 4KB in the earlier kernel version.

Kilobytes per second Read/write
The number of actual data that is read and written to the block device, in kilobytes.

Then from four aspects to think about some of the processing

(Reference: http://blog.chinaunix.net/uid-26413552-id-3193566.html):

The most significant performance impact is the application and operating system two aspects.

There are 4 main factors affecting the performance of Linux operating system: CPU, Memory, disk I/O broadband, network I/O broadband.

On the CPU, use of SMP-enabled Linux memory because most CPUs can only run one thread at a time, and SMP (Hyper-threading) allows multiple threads to run at the same time. In addition, the Linux kernel will be multi-core processor as a number of separate CPU to identify, but performance is not equivalent, the latter overall performance is relatively high.

In memory, small memory can clog up system processes and degrade performance. Too much memory can lead to waste of resources. Linux has the concept of virtual memory and physical memory, you can create virtual memory to alleviate the lack of physical memory, but if the excessive use of virtual memory, the performance of the application will be significantly reduced. 64-bit Linux is recommended because the 64-bit operating system can use more memory, and in a 32-bit Linux operating system, the application's single process can use up to 2G of memory, while the 64-bit system does not have this limitation.

On disk I/O bandwidth, RAID technology can be used to improve I/O performance.

On network I/O broadband, because most Linux applications are now network-based, you need to establish stable, high-speed bandwidth.

21.2 How to improve the boot speed?

(1) flash/disk read/write rate

(2) Drive module stripping, core clipping

(3) Memory cache

(4) Some services can be activated after the machine is released

22. What is a zombie process?

(Refer to http://blog.chinaunix.net/uid-20633888-id-3024864.html)

1 What is a zombie process:

The child process becomes a zombie process when the child process ends before the parent process, and the parent process does not reclaim the child process and frees the resources that the child process occupies. If the parent process exits first, the child process is taken over by Init, and Init reclaims the related resources it occupies after the child process exits.

2 How to clear the zombie process:

1. Rewrite the parent process and bury it after the child process dies. The concrete approach is to take over the SIGCHLD signal. After the child process dies, the SIGCHLD signal is sent to the parent process, and after the parent process receives this signal, the waitpid () function is executed to corpse the child process. This is based on the principle that even if the parent process does not call wait, the kernel sends a SIGCHLD message to it, although the default processing is ignored, and if you want to respond to this message, you can set a handler function.

2. Kill the parent process. After the parent process dies, the zombie process becomes the "orphan process", and the adoptive process init,init will always be responsible for cleaning up the zombie process. All of the zombie processes it produces also disappear.

3 Hazards of the zombie process:

In Unix system management, when observing the execution state of a process with the PS command, it is often seen that the status bar of some processes is defunct, which is called a "zombie" process. The zombie process is a long-dead process, but still occupies a position (slot) in the Process table (processs table). Because the capacity of the process table is limited, the defunct process not only consumes the memory resources of the system, but also affects the performance of the system, and if the number is too large, it can cause the system to become paralyzed.

23. What is big-endian, small end?

Stores low-order bytes at the start address, which is called the small-end (Little-endian) byte order

The high-order bytes are stored at the start address, which is called the big-endian (Big-endian) byte order.

24. What is the host byte order, network byte order, the difference?

The host byte order of the X86 machine is little endian will be the low byte (that is, the right byte, such as 0x1234, then 34 is the low byte) stored in the start address (in the operating system is also a low address)

The network byte order is that the big endian is storing the high byte at the start address (also the low address in the operating system)

The characteristics of 25.RAID0, RAID1, RAID5 and RAID10?

(Refer to http://blog.chinaunix.net/uid-639516-id-2692517.html)

RAID0 (also known as stripe or striping--sub-strips)
That is, data stripping is a sub-strip technology. RAID 0 can connect multiple hard drives into a larger drive group, which can improve disk performance and throughput. RAID 0 has no redundancy or bug fixes, is low cost, requires at least two disks, and is generally only used if the data security requirements are not high.

RAID 0 requires at least two hard drives to be able to achieve, its capacity is the sum of the capacity of each hard disk that makes up the system, the capacity of these hard disks to be the same, in the Home IDE raid in general Cascade two hard drives, must use the same model of the same capacity of the hard disk. RAID 0 Mode writes data to the hard disk when the data is divided into two pieces of hard disk, read the data when the reverse, so that each hard disk as long as the burden of half of the data transmission task, the result is the increase in speed.

2. RAID 1 (also known as mirror or mirroring--mirroring)
RAID 1 is called disk mirroring: The data of one disk is mirrored on another disk, and the reliability and repairable of the system can be guaranteed without compromising the performance, it has high data redundancy, but the disk utilization is 50%, so the cost is the highest, and it is used in the case of saving critical important data. RAID 1 is done by automatically copying the data that the user writes to the drive to a different hard disk.

RAID 1 has the following features:
(1), RAID 1 each disk has a corresponding mirror disk, at any time the data are synchronized mirroring, the system can be from a set of mirrors on any disk to read data.
(2), the disk can use space only half the total disk capacity, the system cost is high.
(3), as long as there is at least one disk in any pair of mirrors in the system can be used, and even in half the number of hard disk problems when the system can operate normally.
(4), a hard disk failure of the RAID system is no longer reliable, should promptly replace the damaged hard disk, or the remaining mirror disk also has problems, then the entire system will crash.
(5), after the replacement of the original data will take a long time to synchronize the image, the external access to the data will not be affected, but the performance of the entire system has declined.
(6), RAID 1 disk controller load is quite large, with multiple disk controllers can improve the security and availability of data.

3. RAID 5

RAID 5 can be understood as a compromise between RAID 0 and RAID 1. RAID 5 can provide data security for the system, but with a lower level of protection than mirror and higher disk space utilization than mirror. RAID 5 has a similar data read speed as RAID 0, with only one parity information, which is slower than writing to a single disk. And because multiple data corresponds to one parity message, RAID 5 has a higher disk space utilization than RAID 1 and a relatively low storage cost.

4. RAID10

RAID10 is also known as a mirror array strip. Like RAID0, data is pumped across the disk; like RAID1, each disk has a mirror disk, so another way to say RAID 10 is raid 0+1. The RAID10 provides 100% data redundancy to support larger volume sizes, but the price is also relatively high. RAID10 provides the best performance for most applications that require only redundancy, regardless of price. With RAID10, you get better reliability, because even if two physical drives fail (one in each array), the data can still be protected. RAID10 requires 4 + 2*n disk drives (N >=0), and can only use half (or smaller, if the disk size is different) disk usage, such as 4 250G hard disk using RAID10 array, the actual capacity is 500G.

RAID Summary:

Type

Read/write performance

Security

Disk Utilization

Cost

Application aspects

RAID0

Best (improved by parallelism)

Worst of all (no security guaranteed)

Highest (100%)

Minimum

Individual users

RAID1

Read and single disk no difference, write to write to both sides

Highest (100% backup for data)

Poor (50%)

Highest

It is suitable for storing important data such as server and database storage areas.

RAID5

READ: RAID 5=raid 0 (similar data read speed)

Write: RAID 5< writes to a single disk (more than one parity message is written)

RAID 5<raid 1

RAID 5>raid 1

RAID 5<raid 1

is a storage solution that combines storage performance, data security, and storage costs.

RAID10

READ: RAID10=RAID0

Written by: Raid10=raid1

Raid10=raid1

RAID10=RAID1 (50%)

Raid10=raid1

The advantages of RAID0,RAID1 are set, but the disk utilization is as much as 50% because of the use of mirroring instead of "parity information" like RAID5 in space.

How many questions can you answer about Linux? --Answer 21-25 questions

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.