You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// requset.go
func get(url string, d time.Duration) {
start := time.Now()
resp, err := http.Get(url)
if err != nil {
fmt.Println(err.Error())
}
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err.Error())
}
d2 := time.Now().Sub(start)
if d2 > d {
fmt.Println(url, d2)
}
}
func main() {
sysGroup := sync.WaitGroup{}
for i := 10; i < 50; i++ {
go func() {
sysGroup.Add(1)
get("http://localhost:8080/wait10s", time.Millisecond*1000)
sysGroup.Done()
}()
}
for i := 0; i < 100; i++ {
go func() {
sysGroup.Add(1)
get("http://localhost:8080/download", time.Millisecond*50)
sysGroup.Done()
}()
}
time.Sleep(time.Millisecond * 20)
for i := 0; i < 100; i++ {
go func() {
sysGroup.Add(1)
get("http://localhost:8080/ping", time.Millisecond*1)
sysGroup.Done()
}()
}
sysGroup.Wait()
}
when request.go run at first time,ping request will back before download request,when request.go run again,ping request will back after download .
Run server with go http ,the problem does not appear。
Description
A Testing
run gin server with code
and then request to the server with code
when request.go run at first time,ping request will back before download request,when request.go run again,ping request will back after download .
Run server with go http ,the problem does not appear。
The text was updated successfully, but these errors were encountered: