Java Golang和apache AB

Java Golang和apache AB,java,go,Java,Go,我有一个带有HTTPPOST请求的系统,它使用Spring5(独立的tomcat)运行。简而言之,它看起来是这样的: 客户端(Apache AB)--->micro服务(java或golang)--->RabbitMQ-->核心(spring+tomcat) 问题是,当我使用Java(Spring)服务时,它还可以。AB显示此输出: ab -n 1000 -k -s 2 -c 10 -s 60 -p test2.sh -A 113:113 -T 'application/json' https:

我有一个带有HTTPPOST请求的系统,它使用Spring5(独立的tomcat)运行。简而言之,它看起来是这样的:

客户端(Apache AB)--->micro服务(java或golang)--->RabbitMQ-->核心(spring+tomcat)

问题是,当我使用Java(Spring)服务时,它还可以。AB显示此输出:

ab -n 1000 -k -s 2 -c 10 -s 60 -p test2.sh -A 113:113 -T 'application/json' https://127.0.0.1:8449/SecureChat/chat/v1/rest-message/send 
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
...
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8449
SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256

Document Path:          /rest-message/send
Document Length:        39 bytes

Concurrency Level:      10
Time taken for tests:   434.853 seconds
Complete requests:      1000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      498000 bytes
Total body sent:        393000
HTML transferred:       39000 bytes
Requests per second:    2.30 [#/sec] (mean)
Time per request:       4348.528 [ms] (mean)
Time per request:       434.853 [ms] (mean, across all concurrent 
requests)
Transfer rate:          1.12 [Kbytes/sec] received
                    0.88 kb/s sent
                    2.00 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4   14   7.6     17      53
Processing:  1110 4317 437.2   4285    8383
Waiting:     1107 4314 437.2   4282    8377
Total:       1126 4332 436.8   4300    8403
ab -n 100 -k -s 2 -c 10 -s 60 -p test2.sh -T 'application/json' http://127.0.0.1:8089/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)...^C

Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8089

Document Path:          /
Document Length:        39 bytes

Concurrency Level:      10
Time taken for tests:   145.734 seconds
Complete requests:      92
Failed requests:        1
   (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Keep-Alive requests:    91
Total transferred:      16380 bytes
Total body sent:        32200
HTML transferred:       3549 bytes
Requests per second:    0.63 [#/sec] (mean)
Time per request:       15840.663 [ms] (mean)
Time per request:       1584.066 [ms] (mean, across all concurrent requests)
Transfer rate:          0.11 [Kbytes/sec] received
                        0.22 kb/s sent
                        0.33 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  1229 1494 1955.9   1262   20000
Waiting:     1229 1291 143.8   1262    2212
Total:       1229 1494 1955.9   1262   20000

That is through plane tcp.
这个输出:

ab -n 1000 -k -s 2 -c 10 -s 60 -p test2.sh -A 113:113 -T 'application/json' https://127.0.0.1:8449/SecureChat/chat/v1/rest-message/send 
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
...
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8449
SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256

Document Path:          /rest-message/send
Document Length:        39 bytes

Concurrency Level:      10
Time taken for tests:   434.853 seconds
Complete requests:      1000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      498000 bytes
Total body sent:        393000
HTML transferred:       39000 bytes
Requests per second:    2.30 [#/sec] (mean)
Time per request:       4348.528 [ms] (mean)
Time per request:       434.853 [ms] (mean, across all concurrent 
requests)
Transfer rate:          1.12 [Kbytes/sec] received
                    0.88 kb/s sent
                    2.00 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4   14   7.6     17      53
Processing:  1110 4317 437.2   4285    8383
Waiting:     1107 4314 437.2   4282    8377
Total:       1126 4332 436.8   4300    8403
ab -n 100 -k -s 2 -c 10 -s 60 -p test2.sh -T 'application/json' http://127.0.0.1:8089/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)...^C

Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8089

Document Path:          /
Document Length:        39 bytes

Concurrency Level:      10
Time taken for tests:   145.734 seconds
Complete requests:      92
Failed requests:        1
   (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Keep-Alive requests:    91
Total transferred:      16380 bytes
Total body sent:        32200
HTML transferred:       3549 bytes
Requests per second:    0.63 [#/sec] (mean)
Time per request:       15840.663 [ms] (mean)
Time per request:       1584.066 [ms] (mean, across all concurrent requests)
Transfer rate:          0.11 [Kbytes/sec] received
                        0.22 kb/s sent
                        0.33 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  1229 1494 1955.9   1262   20000
Waiting:     1229 1291 143.8   1262    2212
Total:       1229 1494 1955.9   1262   20000

That is through plane tcp.
编辑2

func (h *limitHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    select {
    case <-h.connc:


        fmt.Println("ServeHTTP");


        h.handler.ServeHTTP(w, req)

        h.connc <- struct{}{}
    default:
        http.Error(w, "503 too busy", http.StatusServiceUnavailable)
    }
}

limitHandler
的定义在哪里?这似乎对这段代码和问题非常关键。可能不相关,但快速查看http部分会发现您在头之前编写响应,这毫无意义,而且您在
计数器上有一个数据竞争
@Adrian-我添加了LimitHandler,但不是全部。如果
limitHandler
可以作为
http.Handler
返回,那么它必须实现
ServeHTTP
,它没有显示,并且是相关的代码。@Adrian,我想现在已经满了-很抱歉编辑太晚了。
func (h *limitHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    select {
    case <-h.connc:


        fmt.Println("ServeHTTP");


        h.handler.ServeHTTP(w, req)

        h.connc <- struct{}{}
    default:
        http.Error(w, "503 too busy", http.StatusServiceUnavailable)
    }
}
func failOnError(err error, msg string) {
    if err != nil {
        log.Fatalf("%s: %s", msg, err)
        panic(fmt.Sprintf("%s: %s", msg, err))
    }
}