Skip to content

Commit

Permalink
Fix request interval
Browse files Browse the repository at this point in the history
Fix request interval
  • Loading branch information
chrisp018 committed May 21, 2023
2 parents 40d5608 + 438db07 commit 2b3fa5a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
9 changes: 8 additions & 1 deletion app-loadtest/app-loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ var (
Name: "app_loadtest_response_duration_all",
Help: "Duration of HTTP app load test response all requests received",
})

appLoadtestResponseDurationAllValidate = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "app_loadtest_response_duration_all_validate",
Help: "Duration of HTTP app load test response all requests received make sure within 60 seconds",
})
)

var (
Expand All @@ -77,6 +82,7 @@ func init() {
responseSize,
responseDurationEachRequest,
appLoadtestResponseDurationAll,
appLoadtestResponseDurationAllValidate,
)
}

Expand Down Expand Up @@ -173,6 +179,7 @@ func main(){
duration := nextMinute.Sub(currentTime)
fmt.Println("duration :", duration)
nanoseconds := duration.Nanoseconds()
appLoadtestResponseDurationAll.Set(duration.Seconds())
time.Sleep(time.Duration(nanoseconds) * time.Nanosecond)
fmt.Println("nanoseconds :", nanoseconds)
fmt.Println("END:===============================")
Expand All @@ -181,7 +188,7 @@ func main(){
endTimeRequest := time.Now()
loadtestDuration := endTimeRequest.Sub(startTimeRequest)
loadtestSeconds := loadtestDuration.Seconds()
appLoadtestResponseDurationAll.Set(loadtestSeconds)
appLoadtestResponseDurationAllValidate.Set(loadtestSeconds)
fmt.Println("loadtestSeconds: ", loadtestSeconds)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app-loadtest/deploy/02-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
prometheus.io/port: "15020"
prometheus.io/scrape: "true"
spec:
replicas: 4
replicas: 1
selector:
matchLabels:
app: app-loadtest
Expand Down Expand Up @@ -42,7 +42,7 @@ spec:
eks.amazonaws.com/nodegroup: app-request
containers:
- name: app-loadtest
image: 832438989008.dkr.ecr.ap-southeast-1.amazonaws.com/app-loadtest@sha256:05f059352185538396bd6f4056dca78070ca17c646d5069d04e9cb9e45098918
image: 832438989008.dkr.ecr.ap-southeast-1.amazonaws.com/app-loadtest@sha256:53062f98a26ea199df8f027c9ea6baa9f12641f55a2628bf68a4049dd78aa51c
ports:
- name: prometheus
containerPort: 8000
Expand Down
14 changes: 7 additions & 7 deletions app-simulate/deploy/02-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ spec:
port: 5000
initialDelaySeconds: 5
periodSeconds: 5
# resources:
# limits:
# cpu: 200m
# memory: 100Mi
# requests:
# cpu: 150m
# memory: 50Mi
resources:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 50m
memory: 50Mi
2 changes: 1 addition & 1 deletion app-simulate/deploy/04-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
pod: app-simulate
target:
type: AverageValue
averageValue: "3000"
averageValue: "10000"
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down
2 changes: 1 addition & 1 deletion request-simulate/deploy/02-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
spec:
containers:
- name: request-simulate
image: 832438989008.dkr.ecr.ap-southeast-1.amazonaws.com/request-simulate@sha256:4962452cca06c7023978afbee520ce58632c7114724d11de7f3e7d0f58e548ce
image: 832438989008.dkr.ecr.ap-southeast-1.amazonaws.com/request-simulate@sha256:f0cef44a3abd5611056321b81cb2ccea44e2a7df9c5deb7db3c58947872fe7ef
ports:
- name: prometheus
containerPort: 8000
Expand Down
4 changes: 3 additions & 1 deletion request-simulate/request-simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ func putSSMParam(parameterName string, currentTriggerTime string) (error){

func main(){
pastTriggerTime, _ := getSSMParam("/khanh-thesis/past_trigger_time")
replicasCount, _ := getSSMParam("/khanh-thesis/request_simulate_replicas")
numReplicas, _ := strconv.Atoi(replicasCount)
pastTriggerTimeParse, err := time.Parse("2006-01-02 15:04:00", pastTriggerTime)
if err != nil {
log.Fatal(err)
}
fmt.Println("pastTriggerTime: ", pastTriggerTimeParse)
fmt.Println("numReplicas: ", numReplicas)
// temp data
numReplicas := 1
taskQueue := make(chan Task, 1000)
var wg sync.WaitGroup
file, _ := os.Open("wc_dataset_processed.csv")
Expand Down

0 comments on commit 2b3fa5a

Please sign in to comment.