zoukankan      html  css  js  c++  java
  • apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))

    apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))  

     

     
    今天用apache 自带的ab工具测试,当并发量达到1000多的时候报错如下:
    [root@aa~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
     
    Benchmarking 192.168.1.176 (be patient)
    Completed 300 requests
    Completed 600 requests
    Completed 900 requests
    apr_socket_recv: Connection reset by peer (104)
    Total of 1085 requests completed
     
    查看应用服务器和数据库均未报错,连接被重置,bingyi了以下,apr_socket_recv这个是操作系统内核的一个参数,在高并发的情况下,内核会认为系统受到了SYN flood攻击,会发送cookies(possible SYN flooding on port 80. Sending cookies),这样会减慢影响请求的速度,所以在应用服务武器上设置下这个参数为0禁用系统保护就可以进行大并发测试了:
    # vim /etc/sysctl.conf 
    net.ipv4.tcp_syncookies = 0
    # sysctl -p
    然后就可以超过1000个并发测试了。
     
    另附其他系统内核参数说明:
     
    net.ipv4.tcp_syncookies = 0  
    #此参数是为了防止洪水攻击的,但对于大并发系统,要禁用此设置
     
    net.ipv4.tcp_max_syn_backlog
    #参数决定了SYN_RECV状态队列的数量,一般默认值为512或者1024,即超过这个数量,系统将不再接受新的TCP连接请求,一定程度上可以防止系统资源耗尽。可根据情况增加该值以接受更多的连接请求。
     
    net.ipv4.tcp_tw_recycle
    #参数决定是否加速TIME_WAIT的sockets的回收,默认为0。
     
    net.ipv4.tcp_tw_reuse
    #参数决定是否可将TIME_WAIT状态的sockets用于新的TCP连接,默认为0。
     
    net.ipv4.tcp_max_tw_buckets
    #参数决定TIME_WAIT状态的sockets总数量,可根据连接数和系统资源需要进行设置。 
     
    参考:
    http://zhumeng8337797.blog.163.com/blog/static/100768914201262091634698/
  • 相关阅读:
    【leetcode】106. Construct Binary Tree from Inorder and Postorder Traversal
    【leetcode】105. Construct Binary Tree from Preorder and Inorder Traversal
    【leetcode】236. Lowest Common Ancestor of a Binary Tree
    【leetcode】235. Lowest Common Ancestor of a Binary Search Tree
    【leetcode】352. Data Stream as Disjoint Intervals
    【leetcode】897. Increasing Order Search Tree
    【leetcode】900. RLE Iterator
    BEC listen and translation exercise 26
    BEC listen and translation exercise 25
    BEC listen and translation exercise 24
  • 原文地址:https://www.cnblogs.com/archoncap/p/5883723.html
Copyright © 2011-2022 走看看