Last active
June 7, 2021 02:40
-
-
Save jrudio/f925b0a7b23e509906fc25415314594e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Stress Test GET route */ | |
const { check, sleep } = require('k6'); | |
const http = require('k6/http'); | |
// const baseURL = process.env.BASE_URL || 'http://localhost:3002/'; | |
const baseURL = 'http://localhost:3002/'; | |
export const options = { | |
vus: 1000, | |
duration: '60s', | |
thresholds: { | |
// http_req_duration: ['p(95)<2000'], | |
}, | |
}; | |
const idList = []; | |
for (let i = 9899999; i <= 9900099; i += 1) { | |
idList.push(i); | |
} | |
const randomID = () => ( | |
idList[Math.floor(Math.random() * idList.length)] | |
); | |
export default () => { | |
const result = http.get(`${baseURL}api/about/${randomID()}`, { | |
tags: { | |
name: 'service-endpoint', | |
}, | |
}); | |
check(result, { | |
'200 status code': (res) => res.status === 200, | |
}); | |
sleep(1); | |
}; | |
/* | |
/\ |‾‾| /‾‾/ /‾‾/ | |
/\ / \ | |/ / / / | |
/ \/ \ | ( / ‾‾\ | |
/ \ | |\ \ | (‾) | | |
/ __________ \ |__| \__\ \_____/ .io | |
execution: local | |
script: stress/get.js | |
output: - | |
scenarios: (100.00%) 1 scenario, 1000 max VUs, 1m30s max duration (incl. graceful stop): | |
* default: 1000 looping VUs for 1m0s (gracefulStop: 30s) | |
running (1m02.4s), 0000/1000 VUs, 22214 complete and 0 interrupted iterations | |
default ✓ [======================================] 1000 VUs 1m0s | |
✓ 200 status code | |
checks.........................: 100.00% ✓ 22214 ✗ 0 | |
data_received..................: 70 MB 1.1 MB/s | |
data_sent......................: 2.2 MB 34 kB/s | |
http_req_blocked...............: avg=12.6ms min=900ns med=2.2µs max=1.04s p(90)=3.8µs p(95)=11.8µs | |
http_req_connecting............: avg=12.59ms min=0s med=0s max=1.04s p(90)=0s p(95)=0s | |
http_req_duration..............: avg=1.76s min=4.89ms med=1.9s max=2.61s p(90)=1.93s p(95)=1.95s | |
{ expected_response:true }...: avg=1.76s min=4.89ms med=1.9s max=2.61s p(90)=1.93s p(95)=1.95s | |
http_req_failed................: 0.00% ✓ 0 ✗ 22214 | |
http_req_receiving.............: avg=51.86µs min=16.4µs med=50.9µs max=1.12ms p(90)=65.4µs p(95)=74.1µs | |
http_req_sending...............: avg=75.84µs min=4.4µs med=7.6µs max=6.62ms p(90)=20.4µs p(95)=43.93µs | |
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s | |
http_req_waiting...............: avg=1.76s min=4.83ms med=1.9s max=2.6s p(90)=1.93s p(95)=1.95s | |
http_reqs......................: 22214 355.720877/s | |
iteration_duration.............: avg=2.77s min=1s med=2.9s max=4.08s p(90)=2.94s p(95)=2.95s | |
iterations.....................: 22214 355.720877/s | |
vus............................: 664 min=664 max=1000 | |
vus_max........................: 1000 min=1000 max=1000 | |
*/ | |
/* Stress Test POST route */ | |
const { check, sleep } = require('k6'); | |
const http = require('k6/http'); | |
// const baseURL = process.env.BASE_URL || 'http://localhost:3002/'; | |
const baseURL = 'http://localhost:3002/'; | |
const record = { | |
course_id: 1, | |
recent_views: 6676565, | |
description: 'Machine learning is the science of getting computers to act without being explicitly programmed. In the past decade, machine learning has given us self-driving cars, practical speech recognition, effective web search, and a vastly improved understanding of the human genome. Machine learning is so pervasive today that you probably use it dozens of times a day without knowing it. Many researchers also think it is the best way to make progress towards human-level AI. In this class, you will learn about the most effective machine learning techniques, and gain practice implementing them and getting them to work for yourself. More importantly, you\'ll learn about not only the theoretical underpinnings of learning, but also gain the practical know-how needed to quickly and powerfully apply these techniques to new problems. Finally, you\'ll learn about some of Silicon Valley\'s best practices in innovation as it pertains to machine learning and AI. \n\nThis course provides a broad introduction to machine learning, datamining, and statistical pattern recognition. Topics include: (i) Supervised learning (parametric/non-parametric algorithms, support vector machines, kernels, neural networks). (ii) Unsupervised learning (clustering, dimensionality reduction, recommender systems, deep learning). (iii) Best practices in machine learning (bias/variance theory; innovation process in machine learning and AI). The course will also draw from numerous case studies and applications, so that you\'ll also learn how to apply learning algorithms to building smart robots (perception, control), text understanding (web search, anti-spam), computer vision, medical informatics, audio, database mining, and other areas.', | |
learner_career_outcomes: [ | |
{ | |
icon: 'fa-map-signs', | |
pct: 0.33, | |
outcome: 'started a new career after completing these courses', | |
}, | |
{ | |
icon: 'fa-briefcase', | |
pct: 0.32, | |
outcome: 'got a tangible career benefit from this course', | |
}, | |
{ | |
icon: 'fa-money', | |
pct: 0.12, | |
outcome: 'got a pay increase or promotion', | |
}, | |
], | |
metadata: [ | |
{ | |
icon: 'certificate', | |
title: 'Shareable Certificate', | |
subtitle: 'Earn a Certificate upon completion', | |
}, | |
{ | |
icon: 'globe', | |
title: '100% online', | |
subtitle: 'Start instantly and learn at your own schedule', | |
}, | |
{ | |
icon: 'calendar', | |
title: 'Flexible deadlines', | |
subtitle: 'Reset deadlines in accordance to your schedule', | |
}, | |
{ | |
icon: 'clock', | |
title: 'Approx. 60 hours to complete', | |
subtitle: '', | |
}, | |
{ | |
icon: 'speechbubble', | |
title: 'English', | |
subtitle: 'Subtitles: Arabic, French, Portuguese (European), Chinese (Simplified), Italian, Vietnamese, German, Russian, English, Hebrew, Spanish, Hindi, Japanese', | |
}, | |
], | |
what_you_will_learn: [ | |
'Identify a subset of data needed from a column or set of columns and write a SQL query to limit to those results.', | |
'Use SQL commands to filter, sort, and summarize data.', | |
'Create an analysis table from multiple queries using the UNION operator.', | |
'Manipulate strings, dates, & numeric data using functions to integrate data from different sources into fields with the correct format for analysis.', | |
], | |
skills_you_will_gain: [ | |
'Logistic Regression', | |
'Artificial Neural Network', | |
'Machine Learning (ML) Algorithms', | |
'Machine Learning', | |
], | |
}; | |
export const options = { | |
vus: 1000, | |
duration: '60s', | |
thresholds: { | |
// http_req_duration: ['p(95)<2000'], | |
}, | |
}; | |
export default () => { | |
const result = http.post(`${baseURL}api/about/new`, { | |
body: JSON.stringify(record), | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
}, { | |
tags: { | |
name: 'service-post-endpoint', | |
}, | |
}); | |
check(result, { | |
'201 status code': (res) => res.status === 201, | |
}); | |
sleep(1); | |
}; | |
/* | |
/\ |‾‾| /‾‾/ /‾‾/ | |
/\ / \ | |/ / / / | |
/ \/ \ | ( / ‾‾\ | |
/ \ | |\ \ | (‾) | | |
/ __________ \ |__| \__\ \_____/ .io | |
execution: local | |
script: stress/post.js | |
output: - | |
scenarios: (100.00%) 1 scenario, 1000 max VUs, 1m30s max duration (incl. graceful stop): | |
* default: 1000 looping VUs for 1m0s (gracefulStop: 30s) | |
running (1m01.7s), 0000/1000 VUs, 21950 complete and 0 interrupted iterations | |
default ✓ [======================================] 1000 VUs 1m0s | |
✓ 201 status code | |
checks.........................: 100.00% ✓ 21950 ✗ 0 | |
data_received..................: 5.4 MB 88 kB/s | |
data_sent......................: 88 MB 1.4 MB/s | |
http_req_blocked...............: avg=25.45ms min=1.3µs med=2.5µs max=1.07s p(90)=4.11µs p(95)=13.3µs | |
http_req_connecting............: avg=25.44ms min=0s med=0s max=1.07s p(90)=0s p(95)=0s | |
http_req_duration..............: avg=1.76s min=8.53ms med=1.85s max=2.57s p(90)=1.91s p(95)=1.96s | |
{ expected_response:true }...: avg=1.76s min=8.53ms med=1.85s max=2.57s p(90)=1.91s p(95)=1.96s | |
http_req_failed................: 0.00% ✓ 0 ✗ 21950 | |
http_req_receiving.............: avg=54.03µs min=19µs med=51.6µs max=1.17ms p(90)=73.4µs p(95)=86.9µs | |
http_req_sending...............: avg=68.17µs min=6.2µs med=29µs max=16.48ms p(90)=40µs p(95)=60.1µs | |
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s | |
http_req_waiting...............: avg=1.76s min=8.4ms med=1.85s max=2.57s p(90)=1.91s p(95)=1.96s | |
http_reqs......................: 21950 355.995599/s | |
iteration_duration.............: avg=2.79s min=1s med=2.85s max=4.06s p(90)=2.92s p(95)=2.96s | |
iterations.....................: 21950 355.995599/s | |
vus............................: 982 min=982 max=1000 | |
vus_max........................: 1000 min=1000 max=1000 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment