API Academy
🌐 English
  • 🌐 English
  • 🌐 繁體中文
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Testing APIs
  • Introduction
  • Table of Contents
  • API Academy
    • Get Started
      • What is an API?
      • How Does an API Work?
      • How to Call an API?
      • How to Read an API Documentation?
      • Chapter Summary
      • Get realtime weather
    • API Fundamentals
      • API Funtamentals: Overview
      • Method & Path
      • Parameters
      • Request Body
      • Responses
      • API Specification & OAS
      • Chapter Summary
    • Working with APIs
      • Working with APIs: Overview
      • Making Requests from Spec
      • Environments and Variables
      • Chaining Multiple Endpoints
      • Handling Authentication
      • Handling API Signatures
      • Introduction to Scripts
      • Chapter Summary
    • Mocking APIs
      • Mocking APIs: Overview
      • Smart Mock
      • Mock Expectations
      • Cloud Mock
      • Mock Scripts
      • Chapter Summary
    • Designing APIs
      • Designing APIs: Overview
      • Introduction to API Design
      • Creating Your First API Project
      • Analyzing Requirements and Planning Your API
      • Designing Data Models
      • Designing Endpoints
      • Using Components and Reusability
      • Setting Up Authentication
      • API Design Guidelines
      • Chapter Summary
    • Developing APIs
      • Developing APIs: Overview
      • Setup: Install Your AI Coding Assistant
      • Quick Start: From Spec to Running API in 30 Minutes
      • Understanding the Generated Code
      • Testing Your API with Apidog
      • Deployment: Put Your API Online
      • Chapter Summary
    • Testing APIs
      • Testing APIs: Overview
      • Getting Started: Your First Test Scenario
      • Integration Testing and Data Passing
      • Dynamic Values
      • Assertions and Validations
      • Flow Control: If, For, ForEach
      • Data-Driven Testing
      • Performance Testing
      • Test Reports and Analysis
      • CI/CD Integration
      • Scheduled Tasks and Automation
      • Advanced Testing Strategies
      • Chapter Summary
    • API Documentations
      • API Documentations: Overview
      • Publishing Your First API Doc
      • Customizing Documentation Appearance
      • Interactive Features for Consumers
      • Advanced Publishing Settings
      • Managing API Versions
      • Chapter Summary
    • Advanced API Technologies
      • API Technologies: Overview
      • GraphQL
      • gRPC
      • WebSocket
      • Socket.IO
      • Server-Sent Events (SSE)
      • SOAP
      • Chapter Summary
    • API Lifecycle
      • API Lifecycle: Overview
      • Stages of the API Lifecycle
      • API Governance
      • API Security Best Practices
      • Monitoring and Analytics
      • API Versioning Strategies
      • The Future of APIs
      • Chapter Summary
    • API Security
      • API Security: Overview
      • API Security Fundamentals
      • Authentication vs Authorization
      • Understanding OAuth 2.0 and OpenID Connect
      • JSON Web Tokens (JWT)
      • OWASP API Security Top 10
      • Encryption and HTTPS
      • Chapter Summary
    • API Tools
      • API Tools: Overview
      • The Evolution of API Tools
      • API Clients
      • Command Line Tools (cURL, HTTPie)
      • API Design and Documentation Tools
      • API Mocking Tools
      • API Testing Tools
      • All-in-One API Platforms
      • Chapter Summary
    • API Gateway
      • API Gateway: Overview
      • What is an API Gateway?
      • Key Features of API Gateways
      • API Gateway vs Load Balancer vs Service Mesh
      • Popular API Gateway Solutions
      • The BFF (Backend for Frontend) Pattern
      • Chapter Summary
  • Modern Pet Store
    • Pet
      • Get Pet
      • Update Pet
      • Delete Pet
      • Create Pet
      • List Pets
      • Upload Pet Image
    • User
      • Update User
      • Get User
      • Delete User
      • Login
      • Logout
      • Create User
    • Store
      • List Inventory
      • Create Order
      • Get Order
      • Delete Order
      • Callback Example
      • Pay for an Order
    • Payments
      • Pay Order
    • Chat
      • Create Chat Completion
    • Webhooks
      • Pet Adopted Event
      • New Pet Available Event
  • Schemas
    • Pet
    • Category
    • User
    • ApiResponse
    • OrderPayment
    • Tag
    • Order
    • Links-Order
    • PetCollection
    • Bank Card
    • Bank Account
    • Links
    • Error
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Testing APIs

Performance Testing

You've built your API, and it passes all functional tests. But what happens when 100 users try to register at the exact same second? Will it slow down? Will it crash?
Performance Testing is the art of simulating high-traffic scenarios to identify bottlenecks before your users do. Apidog makes this incredibly easy by repurposing your existing test scenarios as performance tests.

What is Performance Testing?#

Unlike functional testing (Does it work?), performance testing asks: How well does it work under load?
Key metrics we care about:
Concurrency: How many virtual users (VUs) are active at once.
Response Time (Latency): How long a request takes (e.g., Average, P99).
Throughput (TPS/RPS): Transactions/Requests Per Second.
Error Rate: Percentage of failed requests.

Configuring a Performance Test#

In Apidog, you don't need to write new scripts. You just take a "Test Scenario" and run it in Performance Mode.

Steps#

1.
Open your Test Scenario (e.g., "User Lifecycle").
2.
Run the scenario, but this time switch the tab to Performance Test instead of Functional Test. (Or click the "Performance" icon).
3.
Configure the Load Parameters:
Virtual Users (concurrency): How many simultaneous threads? Start small (e.g., 20).
Duration: How long to run? (e.g., 1 minute).
Ramp-up Period: How fast to start users? (e.g., 0 to 20 users over 10 seconds).
Performance Test
See details: Performance Testing

Running and Monitoring#

Click Run. Apidog will spawn the virtual users and start hammering your API according to your scenario logic.
You will see a real-time dashboard:
TPS Chart: Is the throughput stable or fluctuating?
Response Time Chart: Is latency increasing over time? (A sign of memory leaks or database locks).
Error Rate: Are we seeing 500 errors?
Performance Test

Analyzing the Report#

Once finished, you get a detailed report.

Key Indicators#

1.
Avg Response Time: If this is higher than 500ms, your API might feel "laggy".
2.
99th Percentile (P99): This is crucial. It means "99% of requests were faster than this". If Avg is 200ms but P99 is 5s, you have a stability problem.
3.
Transactions Per Second (TPS): This is your system's capacity "speed limit".

Real Case: User Registration + Login#

Imagine we want to test the entire onboarding flow under load.
Scenario:
1.
POST /users (Register)
2.
POST /user/login (Login)
Configuration:
Concurrency: 50 Virtual Users.
Duration: 5 Minutes.
Results & Analysis:
TPS: 500 (Good capacity).
Error Rate: 0.5% (Acceptable? Maybe not).
Bottleneck Found: We notice that POST /login is 3x slower than POST /users.
Fix: We discover a missing database index on the email column used during login. After adding it, latency drops by 90%.

Best Practices#

1.
Reuse Scenarios: Don't build separate perf scripts. Use your integration tests.
2.
Start Low: Start with 1 user, then 10, then 50. Don't jump to 1000 immediately.
3.
Isolate Environment: NEVER run performance tests on Production unless you know exactly what you are doing. Use a Staging env.
4.
Watch Dependencies: Often the bottleneck isn't your code, but the Database or a 3rd party API (like Stripe/Twilio) you are calling.

Key Takeaways#

Understand performance metrics (RPS, Latency)
Configure load tests with virtual users
Analyze reports to find bottlenecks

What's Next#

We've tested manually, automatically, and under load. The final piece of the puzzle is analyzing the results over time and sharing them with the team.
In the next chapter, we'll look at Test Reports and Analysis.
Continue with β†’ Test Reports and Analysis
Modified atΒ 2025-12-25 09:53:56
Previous
Data-Driven Testing
Next
Test Reports and Analysis
Built with