[참고자료]
https://github.com/tsenart/vegeta?tab=readme-ov-file
소수를 구하는 코드를 작성한 후 베지터로 측정한 결과이다.
fun findPrime(limit: Int): Long {
var count = 0L
for (i in 2 until limit) {
if (isPrime(i)) {
count++
}
}
return count
}
fun isPrime(number: Int): Boolean {
for (i in 2 until sqrt(number.toDouble()).toInt()) {
if (number % i == 0) return false
}
return true
}
//platform-threads
@GetMapping("/test1")
fun testWithPlatformThreads() {
val threads = mutableListOf<Thread>()
val taskCount = 10_000
val time = measureTimeMillis {
repeat(taskCount) {
val thread = Thread {
findPrime(10_000)
}
threads.add(thread)
thread.start()
}
threads.forEach { it.join() }
}
}
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test1" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.20, 0.46
Duration [total, attack, wait] 34.901s, 4.9s, 30.001s
Latencies [min, mean, 50, 90, 95, 99, max] 17.552s, 26.983s, 30.001s, 30.001s, 30.001s, 30.002s, 30.002s
Bytes In [total, mean] 0, 0.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 32.00%
Status Codes [code:count] 0:34 200:16
Error Set:
Get "http://localhost:8080/sync/test1": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test2" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.18, 0.95
Duration [total, attack, wait] 34.91s, 4.909s, 30s
Latencies [min, mean, 50, 90, 95, 99, max] 10.666s, 21.181s, 21.208s, 30.008s, 30.011s, 30.017s, 30.017s
Bytes In [total, mean] 660, 13.20
Bytes Out [total, mean] 0, 0.00
Success [ratio] 66.00%
Status Codes [code:count] 0:17 200:33
Error Set:
Get "http://localhost:8080/sync/test2": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test3" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.19, 1.23
Duration [total, attack, wait] 34.907s, 4.905s, 30.002s
Latencies [min, mean, 50, 90, 95, 99, max] 877.966ms, 19.724s, 22.325s, 30.006s, 30.013s, 30.027s, 30.027s
Bytes In [total, mean] 1064, 21.28
Bytes Out [total, mean] 0, 0.00
Success [ratio] 86.00%
Status Codes [code:count] 0:7 200:43
Error Set:
Get "http://localhost:8080/sync/test3": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test4" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.18, 0.89
Duration [total, attack, wait] 34.915s, 4.914s, 30.001s
Latencies [min, mean, 50, 90, 95, 99, max] 11.005s, 23.619s, 27.851s, 30.018s, 30.02s, 30.021s, 30.021s
Bytes In [total, mean] 1178, 23.56
Bytes Out [total, mean] 0, 0.00
Success [ratio] 62.00%
Status Codes [code:count] 0:19 200:31
Error Set:
Get "http://localhost:8080/sync/test4": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test5" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.19, 1.35
Duration [total, attack, wait] 34.919s, 4.908s, 30.011s
Latencies [min, mean, 50, 90, 95, 99, max] 786.5ms, 16.169s, 16.341s, 28.769s, 30.011s, 30.02s, 30.02s
Bytes In [total, mean] 1911, 38.22
Bytes Out [total, mean] 0, 0.00
Success [ratio] 94.00%
Status Codes [code:count] 0:3 200:47
Error Set:
Get "http://localhost:8080/sync/test5": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test6" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 49, 9.96, 1.47
Duration [total, attack, wait] 33.355s, 4.918s, 28.437s
Latencies [min, mean, 50, 90, 95, 99, max] 1.369s, 15.324s, 14.968s, 26.753s, 27.83s, 28.556s, 28.556s
Bytes In [total, mean] 1992, 40.65
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:49
Error Set:
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test7" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.20, 1.29
Duration [total, attack, wait] 34.9s, 4.9s, 30s
Latencies [min, mean, 50, 90, 95, 99, max] 785.998ms, 16.753s, 16.945s, 29.855s, 30.001s, 30.002s, 30.002s
Bytes In [total, mean] 2280, 45.60
Bytes Out [total, mean] 0, 0.00
Success [ratio] 90.00%
Status Codes [code:count] 0:5 200:45
Error Set:
Get "http://localhost:8080/sync/test7": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
PS C:\Windows\System32> echo "GET http://localhost:8080/sync/test8" | vegeta attack -duration=5s -rate=10/s -timeout=30s | vegeta report
Requests [total, rate, throughput] 50, 10.20, 1.15
Duration [total, attack, wait] 34.922s, 4.902s, 30.021s
Latencies [min, mean, 50, 90, 95, 99, max] 3.311s, 18.926s, 20.347s, 30.006s, 30.01s, 30.021s, 30.021s
Bytes In [total, mean] 2031, 40.62
Bytes Out [total, mean] 0, 0.00
Success [ratio] 80.00%
Status Codes [code:count] 0:10 200:40
Error Set:
Get "http://localhost:8080/sync/test8": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
아직은 버츄얼쓰레드와 코루틴을 결합하는것은 별로인건가.. 소수구하기 1만 태스크를 5초동안 10회 실행했을 때 성공을 못했다.
ps. 난 버츄얼쓰레드와 코루틴을 결합하면 분명 상호보완관계로써 훌륭이 역할을 수행하리라 믿었는데 결과가 생각보다 좋지않았다.