HTTPerf从文件发送JSON数据

时间:2019-08-07 07:02:47

标签: json httperf apache-utils

需要使用此 httperf ,因为 ab 返回SSL错误。

操作系统

Ubuntu 16 (Google Cloud Linux tools 4.15.0-1036-gcp #38~16.04.1-Ubuntu)

卷曲(卷曲效果很好)

ACCESS_TOKEN=`gcloud auth print-access-token`
export URL=https://ml.googleapis.com/v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict
curl -X POST $URL -d @image_b64.json \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ACCESS_TOKEN" 

ab 测试工具

ab -n 10 -c 1 -s 300 \
-f ALL \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Accept-Encoding: gzip,deflate" \
-p image_b64.json $URL

返回错误,并且在数据包捕获中SSL握手从未完成。我的理解是,apache ab在大多数情况下无法正确处理SSL。参考:How do I fix "ssl handshake failed" with ApacheBench?

Benchmarking ml.googleapis.com (be patient)...SSL write failed - closing connection
..done


Server Software:        
Server Hostname:        ml.googleapis.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128

Document Path:          /v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   0.004 seconds
Complete requests:      1
Failed requests:        0
Total transferred:      0 bytes
Total body sent:        0
HTML transferred:       0 bytes
Requests per second:    254.91 [#/sec] (mean)
Time per request:       3.923 [ms] (mean)
Time per request:       3.923 [ms] (mean, across all concurrent requests)
Transfer rate:          0.00 [Kbytes/sec] received
                        0.00 kb/s sent
                        0.00 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4    4   0.0      4       4
Processing:     0    0   0.0      0       0
Waiting:        0    0   0.0      0       0
Total:          4    4   0.0      4       4

如何配置httperf发送image_b64.json

image_b64.json是〜56K file

httperf --hog --server ml.googleapis.com \
  --uri=/v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict \
  --ssl \
  --method=POST \
  --add-header="Content-Type: application/json\n" \
  --add-header="Authorization: Bearer $ACCESS_TOKEN\n" \
  --timeout=10 --num-conns=10 --rate=1 \
  --wsesslog=150,0,httprefpost_data.txt

我的理解是我需要设置:httprefpost_data.txt

/v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict method=POST contents=

在内容旁边,我想我需要把image_b64.json的全部内容放进去吗?

当我这样做时,我得到:

httperf --hog --server ml.googleapis.com   --uri=/v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict   --ssl   --method=POST   --add-header="Content-Type: application/json\n"   --add-header="Authorization: Bearer $ACCESS_TOKEN\n"   --timeout=10 --num-conns=1 --rate=1   --wsesslog=150,0,httprefpost_data.txt
httperf --hog --timeout=10 --client=0/1 --server=ml.googleapis.com --port=443 --uri=/v1/projects/dpe-cloud-mle/models/pretrained_model/versions/gpu:predict --rate=1 --send-buffer=4096 --recv-buffer=16384 --ssl --add-header='Authorization: Bearer ya29.c.ElxdB5jHc_XhRiuh1kBStykfzIOV9NZBL-Wn1NASWcNmtFj7dzWVc6dlTJdFltP3hYfszayQwe7YFW3tIRhC7v9q7nQDWPTgytrI82-Y4pFCYPRSMveffN4ImYK97Q\n' --method=POST --wsesslog=150,0.000,httprefpost_data.txt
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
httperf: did not recognize arg ':' in httprefpost_data.txt

0 个答案:

没有答案