Skip to content

Commit

Permalink
Revert "feature: test 1000 concurrent requests at a time (#112)" (#114)
Browse files Browse the repository at this point in the history
* Revert "feature: test 1000 concurrent requests at a time (#112)"
  • Loading branch information
kappratiksha authored Aug 10, 2022
1 parent 4d58433 commit c52662e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client/concurrency.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package main
import (
"fmt"
"log"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -124,7 +123,7 @@ func sendConcurrentRequests(sendFn func() error) error {
log.Printf("Single request response time benchmarked, took %s for 1 request", singleReqTime)

// Get a benchmark for the time it takes for concurrent requests
const numConReqs = 1000
const numConReqs = 10
log.Printf("Starting %d concurrent workers to send requests", numConReqs)

type workerResponse struct {
Expand All @@ -148,22 +147,19 @@ func sendConcurrentRequests(sendFn func() error) error {
})

maybeErrMessage := ""
first10Workers := []string{}
for i := 0; i < numConReqs; i++ {
resp := <-respCh
if resp.err != nil {
maybeErrMessage += fmt.Sprintf("error #%d: %v\n", i, resp.err)
}
if i < 10 {
first10Workers = append(first10Workers, fmt.Sprintf("Worker #%d", resp.id))
} else {
log.Printf("Worker #%d done", resp.id)
}
}

if maybeErrMessage != "" {
return fmt.Errorf("at least one concurrent request failed:\n%s", maybeErrMessage)
}

log.Printf("First 10 workers done:\n%s", strings.Join(first10Workers, "\n"))

// Validate that the concurrent requests were handled faster than if all
// the requests were handled serially, using the single request time
// as a benchmark. Some buffer is provided by doubling the single request time.
Expand Down

0 comments on commit c52662e

Please sign in to comment.