安装
基础环境
我使用的系统环境如下:
|
|
安装
-
在pkg中搜索 Apache Bench,由于 Apache Bench 是 apache 自带的性能测试软件,所有我们需要安装
apache
1
pkg search apache
搜索结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
apache-ant-1.10.13 Java- and XML-based build tool, conceptually similar to make apache-bcel-6.4.1 Apache Commons Byte Code Engineering Library apache-commons-beanutils-1.9.4 JavaBeans utility library apache-commons-cli-1.4 Java library for command line arguments and options apache-commons-codec-1.16.0 Implementations of common encoders and decoders apache-commons-collections-3.2.2 Classes that extend/augment the Java Collections Framework apache-commons-collections4-4.4 Classes that extend/augment the Java Collections Framework apache-commons-compress-1.23.0 Classes for working with various archivers apache-commons-configuration-1.10_1 Java package for the reading of configuration/preferences files apache-commons-csv-1.10.0 Java support for Comma Separated Value format apache-commons-daemon-1.3.2 Wrapper code to start/stop a Java application as a daemon apache-commons-dbcp-2.9.0 Apache Commons Database Connection Pool apache-commons-dbutils-1.7 JDBC helper library apache-commons-digester-2.1_2 XML-to-Java-object mapping utility package apache-commons-httpclient-3.1_2 Package implementing the client side of the HTTP standard apache-commons-io-2.11.0 Collection of I/O utilities for Java apache-commons-jelly-1.0_1 XML based scripting engine apache-commons-jxpath-1.3 Utilities for manipulating Java Beans using the XPath syntax apache-commons-lang-2.6 Apache library with helper utilities for the java.lang API apache-commons-lang3-3.12.0 Apache library with helper utilities for the java.lang API apache-commons-logging-1.2 Generic logging wrapper library apache-commons-math-3.6.1_1 Java library of self-contained mathematics and statistics components apache-commons-net-3.9.0 Collection of network protocol implementations for Java apache-commons-pool-2.11.1 Apache Commons Object-pooling API apache-jmeter-2.11_3 Functional behaviour load and performance test application apache-log4j2-2.20.0 Fast and flexible logging library for Java apache-mode.el-2.0_1 Emacs major mode for editing Apache configuration files apache-openoffice-4.1.14_2 Integrated wordprocessor/dbase/spreadsheet/drawing/chart/browser apache-openoffice-devel-4.2.1678061694_2,4 Integrated wordprocessor/dbase/spreadsheet/drawing/chart/browser (developer version) apache-poi-5.2.3 Java API To Access Microsoft Format Files apache-rat-0.13 Release audit tool apache-solr-9.2.1_1,1 High performance search server built using Lucene Java apache-solr8-8.11.2,1 High performance search server built using Lucene Java apache-spark-3.3.0 Fast big data processing engine apache-xml-security-c-2.0.4 Apache XML security libraries - C++ version apache-xmlbeans-5.1.1_1 Java classes for XML apache24-2.4.57_1 Version 2.4.x of Apache web server apachetop-0.19.7 Apache realtime log stats p5-Apache-ASP-2.63 Active Server Pages for Apache p5-Apache-Admin-Config-0.95_1 Perl module to manipulate Apache configuration files p5-Apache-AuthCookie-3.31 Perl module to provide custom forms for reauthentication p5-Apache-AuthTicket-0.94 Perl modules that implement a cookie-based authentication system p5-Apache-Clean-2.00_4 Mod_perl interface into HTML::Clean p5-Apache-Config-Preproc-1.07 Preprocess Apache server configuration files p5-Apache-ConfigFile-1.23_1 Parse Apache style httpd.conf configuration files p5-Apache-ConfigParser-1.02 Load Apache configuration files p5-Apache-DB-0.18_1 Debugging and profiling tools for mod_perl p5-Apache-DBI-1.12_2 DBI persistent connection, authentication and authorization p5-Apache-Defaults-1.03 Get default settings for Apache httpd daemon p5-Apache-Htgroup-1.23_1 Manage Apache authentication group files p5-Apache-Htpasswd-1.9_2 Manage Unix crypt-style password file p5-Apache-LogFormat-Compiler-0.36 Compile a log format string to perl-code p5-Apache-MP3-4.00_4 MP3 browsing and streaming under mod_perl and Apache p5-Apache-ParseFormData-0.09_3 Module allows you to easily decode/parse form and query data p5-Apache-ParseLog-1.02_1 Perl5 module to parse Apache log files p5-Apache-Profiler-0.10_2 Profiles time seconds needed for every request p5-Apache-Session-1.94 Persistence framework for session data p5-Apache-Session-PHP-0.05_1 Glue Apache::Session with PHP::Session p5-Apache-Session-SQLite3-0.03_1 Use DBD::SQLite 1.x for Apache::Session storage p5-Apache-Session-SharedMem-0.6_1 Apache::Session extension that store session in shared memory p5-Apache-Session-Wrapper-0.34_1 Simple wrapper around Apache::Session p5-Apache-SessionX-2.01_1 Extented persistence framework for session data p5-Apache-Singleton-0.17 Singleton class for mod_perl p5-Apache-Solr-1.09 High level interface to the Solr server p5-Apache2-SOAP-0.73_4 Apache2 mod_perl2 SOAP Server p5-Apache2-SiteControl-1.05_3 Perl web site authentication/authorization system p5-ApacheBench-0.73_1 Perl module for HTTP benchmarking p5-CGI-Application-Plugin-Apache-1.02_2 Provides easy access to Apache::* modules for CGI::Application p5-Catalyst-Engine-Apache-1.16_1 Catalyst Apache Engines p5-Config-ApacheFormat-1.2_2 Parse a configuration file in the same syntax as the Apache web server p5-MasonX-Request-WithApacheSession-0.31_2 Interface to Apache::Session for HTML::Mason p5-Text-MultiMarkdown-ApacheHandler-0.01_2 Module for processing files with MultiMarkdown syntax for Apache p5-XML-ApacheFOP-0.03_3 Access Apache FOP from Perl to create PDF files using XSL-FO py39-apache-arrow-8.0.0_3 Columnar in-memory analytics layer for big data py39-apache-beam-2.43.0_1 Apache Beam SDK for Python py39-apache_conf_parser-1.0.1_1 Parse and manipulate apache conf files py39-certbot-apache-2.6.0 Apache plugin for Certbot rubygem-passenger-apache-6.0.17 Modules for running Ruby on Rails and Rack applications
-
安装
从上面搜索的结果来看,pgk 中的
apache
是apache24-2.4.57_1
,安装命令如下:1
pkg install apache24
使用
-
参数说明 我们可以使用 help 查看参数说明:
1
ab --help
-
对接口进行压力测试
1
ab -n 5000 -c 500 http://192.168.0.3:8080/api/v1/hello
返回结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
This is ApacheBench, Version 2.3 <$Revision: 1903618 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.0.3 (be patient) Completed 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests Completed 3500 requests Completed 4000 requests Completed 4500 requests Completed 5000 requests Finished 5000 requests Server Software: # 被测软件信息 Server Hostname: 192.168.0.3 # 被测主机名 Server Port: 8080 # 被测服务端口 Document Path: /api/v1/hello # 测试的文档页面 Document Length: 11 bytes # 测试的文档大小 Concurrency Level: 500 # 并发数 Time taken for tests: 0.795 seconds # 整个测试持续的时间 Complete requests: 5000 # 完成的请求数量 Failed requests: 0 # 失败的请求数量 Total transferred: 640000 bytes # 整个测试中网络传输量 HTML transferred: 55000 bytes # 整个测试中HTML传输量 Requests per second: 6288.87 [#/sec] (mean) # 每秒处理的请求数(请求数), mean 表示这是一个平均数 Time per request: 79.506 [ms] (mean) # 用户平均请求等待时间 Time per request: 0.159 [ms] (mean, across all concurrent requests) # 服务器平均请求等待时间 Transfer rate: 786.11 [Kbytes/sec] received # 带宽传输速度 Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.8 0 16 Processing: 6 74 36.7 63 251 Waiting: 0 74 36.7 63 251 Total: 11 75 37.2 63 258 Percentage of the requests served within a certain time (ms) 50% 63 66% 82 75% 96 80% 105 90% 127 95% 145 98% 169 99% 207 100% 258 (longest request)