Skip to content

Commit a41e9e1

Browse files
committed
continue to fix bugs
1 parent 5273489 commit a41e9e1

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

2setup.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
## 这个脚本使用Docker在不同的网络命名空间产生多个client实例.
3+
## 这样才能避免source port的限制,在一台机器上才能创建百万的连接.
4+
##
5+
## 用法: ./connect <connections> <number of clients> <server ip>
6+
## Server IP 通常是 Docker gateway IP address, 缺省是 172.17.0.1
7+
8+
CONNECTIONS=$1
9+
REPLICAS=$2
10+
IP=$3
11+
#go build --tags "static netgo" -o client client.go
12+
13+
for (( c=0; c<${REPLICAS}; c++ ))
14+
do
15+
docker run -v $(pwd)/client:/client --name 1mclient_$c -d alpine /client \
16+
-conn=${CONNECTIONS} -ip=${IP}
17+
done

4_epoll_client/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
var (
1717
ip = flag.String("ip", "127.0.0.1", "server IP")
1818
connections = flag.Int("conn", 1, "number of tcp connections")
19-
startMetric = flag.String("sm", time.Now().Format("2006-01-02T15:04:05"), "start time point of all clients")
19+
startMetric = flag.String("sm", time.Now().Format("2006-01-02T15:04:05 -0700"), "start time point of all clients")
2020
)
2121

2222
var (
@@ -31,7 +31,7 @@ func main() {
3131
setLimit()
3232

3333
go func() {
34-
startPoint, err := time.Parse("2006-01-02T15:04:05", *startMetric)
34+
startPoint, err := time.Parse("2006-01-02T15:04:05 -0700", *startMetric)
3535
if err != nil {
3636
panic(err)
3737
}

5_multiple_client/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
ip = flag.String("ip", "127.0.0.1", "server IP")
1818
connections = flag.Int("conn", 1, "number of total tcp connections")
1919
c = flag.Int("c", 100, "currency count")
20-
startMetric = flag.String("sm", time.Now().Format("2006-01-02T15:04:05"), "start time point of all clients")
20+
startMetric = flag.String("sm", time.Now().Format("2006-01-02T15:04:05 -0700"), "start time point of all clients")
2121
)
2222

2323
var (
@@ -30,7 +30,7 @@ func main() {
3030

3131
setLimit()
3232
go func() {
33-
startPoint, _ := time.Parse("2006-01-02T15:04:05", *startMetric)
33+
startPoint, _ := time.Parse("2006-01-02T15:04:05 -0700", *startMetric)
3434
time.Sleep(startPoint.Sub(time.Now()))
3535

3636
metrics.Log(metrics.DefaultRegistry, 5*time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))

report.sh

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
REPLICAS=$1
44

5+
rm -f metrics.log
6+
57
for (( c=0; c<${REPLICAS}; c++ ))
68
do
79
docker logs 1mclient_$c|egrep "mean|stddev"|tail -3 >> metrics.log

setup.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ REPLICAS=$2
1010
IP=$3
1111
#go build --tags "static netgo" -o client client.go
1212

13-
DATE=`date -d "+5 minutes" +"%FT%T"`
13+
DATE=`date -d "+2 minutes" +"%FT%T %z"`
1414
for (( c=0; c<${REPLICAS}; c++ ))
1515
do
16-
docker run -v $(pwd)/client:/client --name 1mclient_$c -d frolvlad/alpine-glibc /client \
17-
-conn=${CONNECTIONS} -ip=${IP} -sm ${DATE}
16+
docker run -v $(pwd)/client:/client --name 1mclient_$c -d alpine /client \
17+
-conn=${CONNECTIONS} -ip=${IP} -sm "${DATE}"
1818
done

setupm.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ REPLICAS=$2
1010
IP=$3
1111
CONCURRENCY=$4
1212

13-
DATE=`date -d "+5 minutes" +"%FT%T"`
13+
DATE=`date -d "+2 minutes" +"%FT%T %z"`
1414

1515
for (( c=0; c<${REPLICAS}; c++ ))
1616
do
17-
docker run -v $(pwd)/mclient:/client --name 1mclient_$c -d frolvlad/alpine-glibc /client \
18-
-conn=${CONNECTIONS} -ip=${IP} -c=${CONCURRENCY} -sm ${DATE}
17+
docker run -v $(pwd)/mclient:/client --name 1mclient_$c -d alpine /client \
18+
-conn=${CONNECTIONS} -ip=${IP} -c=${CONCURRENCY} -sm "${DATE}"
1919
done

0 commit comments

Comments
 (0)