# myCloudgo
**Repository Path**: alphabstc/my-cloudgo
## Basic Information
- **Project Name**: myCloudgo
- **Description**: 开发简单 web 服务程序 cloudgo,了解 web 服务器工作原理。
static文件夹下为Web应用所用静态资源文件(jss cs images)。
templates为Web应用所用html模板文件。
main.go及service文件夹下为Web应用后端的go代码文件。
- **Primary Language**: Go
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-11-24
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 项目组成说明
static文件夹下为Web应用所用静态资源文件(jss cs images)。
templates为Web应用所用html模板文件。
main.go及service文件夹下为Web应用后端的go代码文件。
## 测试
更详细文档请见https://blog.csdn.net/STcyclone/article/details/110001831
### curl测试
在打开服务器程序的条件下,在另一个Shell中进行curl测试。
访问主页localhost:8000:
curl -v http://localhost:8000
* Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Date: Sat, 21 Nov 2020 17:07:17 GMT
< Content-Length: 484
<
This is My Sample Go Web Application.
The message1 is
The message2 is
The designer is
* Connection #0 to host localhost left intact
访问localhost:8000/hello/100:
curl -v http://localhost:8000/hello/100
* Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /hello/100 HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Date: Sat, 21 Nov 2020 17:17:03 GMT
< Content-Length: 26
<
{
"Test": "Hello 100"
}
* Connection #0 to host localhost left intact
访问localhost:8000/js/:
curl -v http://localhost:8000/js/
* Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /js/ HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Last-Modified: Sat, 21 Nov 2020 15:16:09 GMT
< Date: Sat, 21 Nov 2020 17:20:44 GMT
< Content-Length: 79
<
index.js
sorter.js
* Connection #0 to host localhost left intact
访问localhost:8000/js/index.js:
curl -v http://localhost:8000/js/index.js
* Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /js/index.js HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 297
< Content-Type: application/javascript
< Last-Modified: Sat, 21 Nov 2020 16:15:26 GMT
< Date: Sat, 21 Nov 2020 17:22:43 GMT
<
$(document).ready(function() {
$.ajax({
url: "/hello/100"
}).then(function(data) {
$('#text1').append(data.Test);
});
$.ajax({
url: "/api/test"
}).then(function(data) {
$('#text2').append(data.id);
$('#text3').append(data.user);
});
* Connection #0 to host localhost left intact
});
访问localhost:8000/signup:
curl -v http://localhost:8000/signup
* Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /signup HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Date: Sat, 21 Nov 2020 17:24:52 GMT
< Content-Length: 333
<
Sign Up
* Connection #0 to host localhost left intact
### ab测试
对主页执行1000次请求,并发等级为10:
ab -n 1000 -c 10 http://localhost:8000/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software:
Server Hostname: localhost
Server Port: 8000
Document Path: /
Document Length: 484 bytes
Concurrency Level: 10
Time taken for tests: 0.449 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 601000 bytes
HTML transferred: 484000 bytes
Requests per second: 2225.10 [#/sec] (mean)
Time per request: 4.494 [ms] (mean)
Time per request: 0.449 [ms] (mean, across all concurrent requests)
Transfer rate: 1305.94 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 6
Processing: 0 4 2.7 4 16
Waiting: 0 4 2.7 4 16
Total: 0 4 2.7 4 16
Percentage of the requests served within a certain time (ms)
50% 4
66% 5
75% 6
80% 6
90% 8
95% 10
98% 11
99% 12
100% 16 (longest request)
平均一秒处理2225个请求,还是比较快的。
对注册页执行2000次请求,并发等级为20:
ab -n 2000 -c 20 http://localhost:8000/signup
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests
Server Software:
Server Hostname: localhost
Server Port: 8000
Document Path: /signup
Document Length: 333 bytes
Concurrency Level: 20
Time taken for tests: 0.952 seconds
Complete requests: 2000
Failed requests: 0
Total transferred: 900000 bytes
HTML transferred: 666000 bytes
Requests per second: 2101.21 [#/sec] (mean)
Time per request: 9.518 [ms] (mean)
Time per request: 0.476 [ms] (mean, across all concurrent requests)
Transfer rate: 923.38 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 8
Processing: 0 9 4.1 9 32
Waiting: 0 9 4.1 9 26
Total: 0 9 4.0 9 32
Percentage of the requests served within a certain time (ms)
50% 9
66% 10
75% 11
80% 12
90% 14
95% 17
98% 20
99% 22
100% 32 (longest request)
平均一秒处理2101个请求,也是比较快的。
对hello/100执行3000次请求,并发等级为20:
ab -n 3000 -c 20 http://localhost:8000/hello/100
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
Completed 1200 requests
Completed 1500 requests
Completed 1800 requests
Completed 2100 requests
Completed 2400 requests
Completed 2700 requests
Completed 3000 requests
Finished 3000 requests
Server Software:
Server Hostname: localhost
Server Port: 8000
Document Path: /hello/100
Document Length: 26 bytes
Concurrency Level: 20
Time taken for tests: 1.261 seconds
Complete requests: 3000
Failed requests: 0
Total transferred: 447000 bytes
HTML transferred: 78000 bytes
Requests per second: 2379.26 [#/sec] (mean)
Time per request: 8.406 [ms] (mean)
Time per request: 0.420 [ms] (mean, across all concurrent requests)
Transfer rate: 346.20 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 6
Processing: 0 8 3.6 8 20
Waiting: 0 8 3.6 8 20
Total: 0 8 3.6 8 21
Percentage of the requests served within a certain time (ms)
50% 8
66% 9
75% 10
80% 11
90% 13
95% 16
98% 17
99% 18
100% 21 (longest request)
平均一秒处理2379个请求,也是比较快的。
解释测试结果的重要参数:
- Server Software:使用的Server软件
- Server Hostname:Server的主机名称
- Server Port:Server的端口号
- Document Path:请求的url路径
- Document Length:返回文档的长度
- Concurrency Level:ab测试中请求的并发等级,数值越高则并发度越大
- Time taken for tests:ab测试所用时间
- Complete requests:ab测试完成的请求数量
- Failed requests:失败的请求数量
- Total transferred:总计传输报文长度
- HTML transferred:传输的HTML长度
- Requests per second:平均每秒处理的请求
- Time per request:一个请求的平均处理时间
- Transfer rate:传输速率
- Connection Times:http连接时间