zoukankan      html  css  js  c++  java
  • Coherence生产环境异常定位过程

    8月1日前广西发生了一次地震, 8月份前又发生了好几次台风,估计对地下的光缆有点损害(比如5根断了2根之类),感觉家里的网速都慢了好多,在客户那里部署的coherence缓存环境也出现了问题,两台hp小机构成的coherence集群环境,客户压力一大就处于集群不可用状态.但停任何一台后,另外一台都能对外提供还算稳定的服务。

    针对HP小机服务器的环境,通过运行Coherence自带的网络测试工具datagram-test.sh程序进行了测试,发现如下问题:

    在运行Coherence集群的状态下,两台HP小机服务器会出现大量的报文丢包现象,大概50%左右。

    两台hp机器之间做diagram-test.sh的情况

    一台没有启动coherence的hp和另外一台linux间报文传输情况

    同时,对网络传输速度进行测试,发现这两台HP服务器之间的网络传输速度明显低于同一网络下其他服务器之间传输速度。

    基于测试情况,直接怀疑是网络因素导致问题的出现。


    为了排除问题,我们在linux环境中重新建立了环境,并进行了参数优化

    主要优化内容包括:

    • 调整Linux服务器内核参数,调整的参数包括:

    vi /etc/sysctl.conf

    在文件尾部追加以下内容

    fs.aio-max-nr = 1048576

    fs.file-max = 6815744

    kernel.shmall = 2097152

    kernel.shmmax = 4294967295

    kernel.shmmni = 4096

    kernel.sem = 250 32000 100 128

    net.ipv4.ip_local_port_range = 9000 65500

    net.core.rmem_default = 262144

    net.core.rmem_max = 4194304

    net.core.wmem_default = 262144

    net.core.wmem_max = 1048576

    使内核生效

    sysctl –p

    • 设置Coherence采用ipv4模式

    启动命令中加入java.net.preferIPv4Stack=true

    • 设置Coherence绑定ip网段的参数

    在tangosol-coherence-override.xml中设置

    <address system-property="tangosol.coherence.localhost">10.150.22.0/16</address>

          <port system-property="tangosol.coherence.localport">8088</port>

          <port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>

          <priority>8</priority>

    • 调整Coherence的线程设置,在配置文件中加入thread-count

    <distributed-scheme>

                              <scheme-name>distributed-scheme</scheme-name>

                              <service-name>DistributedCache</service-name>

                              <thread-count>50</thread-count>

                   

    进行测试的时候发现并发压力一大,同样出现很多错误。错误内容在网络上检查不到任何信息。为此进行第二次优化

    • 客户相关技术人员针对Linux服务器的交换机进行了网络调整与优化
    •  修改了Linux服务器的内核的TCP参数优化

    vi /etc/sysctl.conf

    在文件尾部追加以下内容

    net.ipv4.tcp_tw_recycle=1

    net.ipv4.tcp_tw_reuse=1

    net.ipv4.tcp_max_syn_backlog=65536

    net.core.somaxconn=32768

    net.ipv4.tcp_syn_retries=1

    net.ipv4.tcp_synack_retries=1

    net.ipv4.icp_fin_timeout =2

    net.ipv4.tcp_keepalive_intvl = 75

    Net.ipv4.tcp_wmem=8192 131072 16777216

    Net.ipv4.tcp_rmem=3276 131072 16777216

    net.ipv4.ip_local_port_range = 3000 65500

    net.core.netdev_max_backlog=32768

    使内核生效

    sysctl –p

    • 技术人员重新安装了Coherence软件
    • 将Coherence的组播方式转变成单播方式,修改Coherence配置,加入

    <well-known-addresses>

            <socket-address id="1">

              <address system-property="tangosol.coherence.wka">10.150.22.24</address>

              <port system-property="tangosol.coherence.wka.port">8088</port>

            </socket-address>

            <socket-address id="2">

              <address system-property="tangosol.coherence.wka">10.150.22.25</address>

              <port system-property="tangosol.coherence.wka.port">8090</port>

            </socket-address>                

          </well-known-addresses>

    在优化后,通过LoadRunner进行了压力测试,可以看到网络压力,1G的带宽环境网络吞吐最多能达到100m/s。

    • 在linux环境中,在网络带宽跑满的状况下,运行diagram-test并不丢包。
    • 而在hp小机环境下,一台测试时发现网络压力上不去,应该是具备一些自我保护手段,不让报文频繁攻击。保证稳定性。因此发现diagram-test经常丢包。

    截图更多的是在linux上压力测试的带宽情况

    第二天生产环境中网络带宽情况

    结论和总结:

    • Coherence对网络非常敏感,diagram-test.sh和multicasttest.sh是针对网络环境很好的测试工具,引用手册:

    The primary items of interest are the throughput and success rate. The goal is to find the highest throughput while maintaining a success rate as close to 1.0 as possible. On a 100 Mb network setup you should be able to achieve rates of around 10 MB/sec. On a 1 Gb network you should be able to achieve rates of around 100 MB/sec. Achieving these rates will likely require some tuning (see below).

    • 了解到hp小机确实是有一些机制来保障稳定性,在压力大的时候drop掉报文
    • 在很难定位问题情况下,必须尝试重新安装Coherence.
  • 相关阅读:
    django 一对多操作
    django 单表常用操作
    element-ui
    vue与后台交互之post用法
    pip换国内源
    TCP/UDP的理解
    进程/线程/协程的理解
    《手牵手带你走进python世界》系列四
    《手牵手带你走进python世界》系列五
    《手牵手带你走进python世界》系列三
  • 原文地址:https://www.cnblogs.com/ericnie/p/5817972.html
Copyright © 2011-2022 走看看