Sword refers to the tuning of the architect series-linux

Source: Internet
Author: User
Tags rfc cpu usage

1. I/O tuning

The iostat command output under CentOS is as follows:

$iostat-D-K 1 2  # view TPS and throughput

The parameter-D indicates that the device (disk) usage status is displayed; k Some columns that use block are forced to use kilobytes; 1 10 indicates that the data is refreshed every 1 seconds and is displayed 2 times.

TPS: The number of times the device is transferred per second, which is an I/O request. Multiple logical requests may be merged into "one I/O request". The size of the "one transfer" request is unknown.

KB_READ/S: The amount of data read from the device per second, KB_WRTN/S: The amount of data written to the device per second, Kb_read: Total data Read, KB_WRTN: The total amount of data written, and the units are kilobytes.

Common usage is as follows:

iostat-d-x-k 1 2   # View Device usage (%util), Response time (r_await/w_await milliseconds)

If%util is close to 100%, it indicates that there are too many I/O requests, the I/O system is full, and the disk may have bottlenecks.

Avgqu-sz is also an IO tuning need to pay attention to, this is the direct operation of the size of the data, if the number of times, but the small amount of data, in fact, the IO will be very small. If the data is large, the IO data will be high

Iostat-c 1 2         # View CPU Status

 

Idle less than 70% io pressure is larger, the general reading speed has more wait.

Vmstat 2 1  # 2 seconds sampled, 1 times

  

b indicates the number of processes waiting for the resource; WA indicates the percentage of CPU time that IO waits for, higher than 30% when IO pressure is high

Improve IO Performance:

(1) Increase the cache, reduce the number of times to access the disk

(2) RAID boost IO for disk

(3) Indexing data, or using asynchronous and non-blocking methods to speed access to disk

2. View CPU

First look at the CPU load, the address is as follows:

http://blog.csdn.net/tonyxf121/article/details/46637423

1. Top command: Linux command. You can view real-time CPU usage. You can also view CPU usage for the most recent period of time.

2, PS command: Linux command. Powerful process status monitoring commands. You can view the current CPU usage of the process and threads in the process. The sampled data that belongs to the current state.

3, the Jstack:java provides the command. You can view the current thread stack run of a process. Depending on the output of this command, you can locate the current running state of all threads of a process, run code, deadlock, and so on.

4, Pstack:linux command. You can view the current thread stack run of a process.

3, TCP network parameter tuning

You can use the Apache AB tool to test the server and install the AB tool:

Yum-y Install Httpd-tools

and then test it.

Ab-c 10-n 192.168.1.127-c 10 indicates that the number of concurrent users is 10-n 100 indicates that the total number of requests is 100

Common parameter tuning is as follows:

Net.core.netdev_max_backlog = 400000# This parameter determines the maximum number of packets that are allowed to be sent to the queue when the network device receives a packet at a rate that is faster than the rate at which the kernel processes the packets. Net.core.optmem_max = 10000000# This parameter specifies the size of the maximum buffer allowed for each socket Net.core.rmem_default = 10000000# Specifies the default value (in bytes) for the receive socket buffer size. Net.core.rmem_max = 10000000# Specifies the maximum value, in bytes, of the receive socket buffer size. Net.core.somaxconn = 100000#linux kernel parameter, which represents the upper limit of the backlog (listening queue) of the socket listener Net.core.wmem_default = 11059200# defines the default Send window size For the larger BDP, this size should also be larger. Net.core.wmem_max = 11059200# defines the maximum size of the sending window, which should be larger for larger BDP. Net.ipv4.conf.all.rp_filter = 1net.ipv4.conf.default.rp_filter = # rigorous mode 1 (recommended) #松散模式 0 Net.ipv4.tcp_congestion_control = bic# default recommended setting is Htcp net.ipv4.tcp_window_scaling = 0# off tcp_window_scaling# enable window scaling defined by RFC 1323; To support windows larger than 64KB, you must enable the Value. NET.IPV4.TCP_ECN = 0# Turn off TCP's direct congestion notification (TCP_ECN) Net.ipv4.tcp_sack = # Close tcp_sack# Enable selective answer (selective acknowledgment), # This can improve performance by selectively responding to messages received in a random order (which allows the sender to send only the missing segment); # (for WAN traffic) This option should be enabled, but this will increase the CPU footprint. Net.ipv4.tcp_max_tw_buckets = 10000# Indicates the maximum number of time_wait sockets that the system maintains simultaneously net.ipv4.tcp_max_syn_backlog = 8192# tableThe SYN queue Length, default 1024, is changed to 8192, which can accommodate more network connections waiting to be connected. Net.ipv4.tcp_syncookies = # means to open syn Cookies. When there is a SYN wait queue overflow, cookies are enabled to handle a small number of SYN attacks, and the default is 0, which means close; net.ipv4.tcp_timestamps = # open TCP Timestamp # A more accurate method of sending timeouts in a specific proportion (see RFC 1323) to enable the calculation of the RTT; This option should be enabled for better performance. Net.ipv4.tcp_tw_reuse = # means turn on reuse. Allows the time-wait sockets to be reused for new TCP connections, which defaults to 0, which means close, Net.ipv4.tcp_tw_recycle = # indicates a fast recycle of time-wait sockets on a TCP connection, and the default is 0, which means shutdown. Net.ipv4.tcp_fin_timeout = 10# means that if the socket is closed by the local side, this parameter determines how long it remains in the fin-wait-2 state. Net.ipv4.tcp_keepalive_time = 1800# indicates the frequency at which TCP sends keepalive messages when KeepAlive is employed. The default is 2 hours, which is changed to 30 minutes. Net.ipv4.tcp_keepalive_probes = 3# If the other party does not answer, the number of packets sent NET.IPV4.TCP_KEEPALIVE_INTVL = 15#keepalive probe packet send interval net.ipv4.tcp _mem# determines how the TCP stack should reflect memory usage, and the units of each value are memory pages (typically 4KB). #第一个值是内存使用的下限. #第二个值是内存压力模式开始对缓冲区使用应用压力的上限. #第三个值是内存上限. At this level, messages can be discarded, thereby reducing the use of memory. For larger BDP You can increase these values (but remember that their units are memory pages, not bytes). net.ipv4.tcp_rmem# is similar to Tcp_wmem, but it represents the value of the receive buffer used for automatic tuning. Net.ipv4.tcp_wmem = 30000000 30000000 30000000# defines the memory used by each socket for automatic tuning. The minimum number of bytes allocated #第一个值是为 the send buffer for the socket. #第二个值是默认值 (this value is Wmem_defaULT), the buffer can grow to this value when the system load is not heavy. #第三个值是发送缓冲区空间的最大字节数 (the value is overwritten by Wmem_max). Net.ipv4.ip_local_port_range = 1024 65000# indicates the range of ports used for an outward connection. Small by default: 32768 to 61000, 1024 to 65000. net.ipv4.netfilter.ip_conntrack_max=204800# setting the system's limit on the maximum number of tracked TCP connections Net.ipv4.tcp_slow_start_after_idle = 0# Closes the slow start of a TCP connection transfer, which is a period of inactivity before initializing the congestion window. Net.ipv4.route.gc_timeout = 100# The route cache refresh rate, the default is 300 when a route fails to jump to another route for a long time. Net.ipv4.tcp_syn_retries = # number of SYN packets sent before the kernel abandons the connection. net.ipv4.icmp_echo_ignore_broadcasts = # Avoid amplification attack net.ipv4.icmp_ignore_bogus_error_responses = # turn on malicious ICMP error message protection net.inet.udp.checksum=1# an attack that prevents an incorrect UDP packet Net.ipv4.conf.default.accept_source_route = 0# accepts IP packets that contain source routing information. The parameter value is a Boolean value, 1 is accepted, and 0 is not accepted. #在充当网关的linux主机上缺省值为1, the default value is 0 on a typical Linux host. #从安全性角度出发, it is recommended that you turn off this feature.

  

Reference article:

Http://www.ha97.com/4546.html

Http://www.ha97.com/5095.html

Sword refers to the tuning of the architect series-linux

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.