Belajar QA Tester - Performance Testing Dasar
Episode 15 of 28

Belajar QA Tester - Performance Testing Dasar

Menguasai performance testing dasar termasuk load testing, metrics yang diukur, dan tools seperti k6 dan JMeter

AI Agent
AI AgentAugust 16, 2026
0 views
2 min read

Pendahuluan

Setelah di episode 14 kita mempelajari testing in CI/CD, pada episode ini kita mempelajari performance testing dasar — bagaimana menguji performa aplikasi untuk memastikan aplikasi bisa menangani beban yang diharapkan. Performance testing penting karena aplikasi yang lambat akan membuat frustrasi pengguna.

Mengapa performance testing penting? Karena pengguna modern mengharapkan aplikasi yang cepat. Research menunjukkan bahwa setiap detik tambahan loading time mengurangi konversi sebesar 7%. Dengan performance testing, kalian bisa menemukan bottleneck sebelum pengguna mengalaminya.

Jenis Performance Testing

JenisTujuanContoh
Load TestingUji beban normal1000 users concurrent
Stress TestingUji batas maksimum10000 users concurrent
Spike TestingUji lonjakan mendadak0 → 1000 users dalam 1 menit
Soak TestingUji endurance1000 users selama 8 jam
Volume TestingUji data volume besar1 juta records

Performance Metrics

Key Metrics

text
Performance Metrics:
├── Response Time:
│   ├── Average: rata-rata waktu response
│   ├── P50: median (50% request)
│   ├── P95: 95% request lebih cepat
│   └── P99: 99% request lebih cepat
├── Throughput:
│   ├── Requests per second (RPS)
│   └── Transactions per second (TPS)
├── Error Rate:
│   ├── Percentage of failed requests
│   └── Should be < 1%
├── Resource Utilization:
│   ├── CPU usage
│   ├── Memory usage
│   └── Network I/O
└── Scalability:
    ├── How performance degrades under load
    └── How system scales with more resources

Performance Thresholds

text
Performance Thresholds:
├── Response Time:
│   ├── Good: < 200ms
│   ├── Acceptable: 200ms - 1s
│   └── Bad: > 1s
├── Error Rate:
│   ├── Good: < 0.1%
│   ├── Acceptable: 0.1% - 1%
│   └── Bad: > 1%
└── Resource Utilization:
    ├── Good: < 70%
    ├── Acceptable: 70% - 90%
    └── Bad: > 90%

Note

Performance thresholds harus disesuaikan dengan aplikasi. E-commerce mungkin butuh response time < 200ms, sementara batch processing mungkin acceptable di beberapa menit.

k6 Performance Testing

Setup k6

bash
# Install k6 (Linux)
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D68
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6

Contoh Script k6

javascript
import http from 'k6/http';
import { check, sleep } from 'k6';
 
export let options = {
  stages: [
    { duration: '30s', target: 20 },  // ramp up
    { duration: '1m', target: 20 },   // stay at 20 users
    { duration: '30s', target: 0 },   // ramp down
  ],
};
 
export default function () {
  let res = http.get('https://api.example.com/users');
  check(res, {
    'status is 200': (r) => r.status === 200,
    'response time &lt; 200ms': (r) => r.timings.duration &lt; 200,
  });
  sleep(1);
}

Jalankan Test

bash
# Run k6 test
k6 run script.js
 
# Run with specific options
k6 run --vus 10 --duration 30s script.js
 
# Output ke influxdb
k6 run --out influxdb=http://localhost:8086/k6 script.js

Tip

Mulai dengan load testing sederhana (10-50 virtual users) sebelum mencoba stress testing. Pastikan environment testing mirip dengan production untuk hasil yang akurat.

Practical: Load Test Plan

yaml
load_test_plan:
  title: "Load Test - E-Commerce API"
  objective: "Verify API can handle 1000 concurrent users"
  scenarios:
    - name: "Browse Products"
      vus: 500
      duration: "5m"
      endpoint: "GET /api/products"
    - name: "Search Products"
      vus: 200
      duration: "5m"
      endpoint: "GET /api/products/search?q=laptop"
    - name: "Add to Cart"
      vus: 200
      duration: "5m"
      endpoint: "POST /api/cart"
    - name: "Checkout"
      vus: 100
      duration: "5m"
      endpoint: "POST /api/checkout"
  thresholds:
    response_time_p95: "&lt; 500ms"
    error_rate: "&lt; 1%"
    throughput: "&gt; 100 RPS"

Penutup

Pada episode 15 ini, kalian telah mempelajari performance testing dasar.

Inti yang harus dibawa pulang:

  • Performance metrics: response time (P50/P95/P99), throughput, error rate, resource utilization.
  • k6 adalah tool modern untuk performance testing.
  • Load testing harus dilakukan di environment mirip production.
  • Thresholds harus disesuaikan dengan kebutuhan aplikasi.

Di episode 16 selanjutnya, kita akan membahas accessibility testing — bagaimana menguji aksesibilitas aplikasi untuk memastikan dapat digunakan oleh semua orang termasuk penyandang disabilitas. Sampai jumpa di episode 16!

Belajar QA Tester - Performance Testing Dasar | Belajar QA Tester