Testing the Performance of API with POSTMAN
Introduction:
An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other. Apart from functional testing, it is important to ensure that an API performs reliably under pressure. Performance testing often uses separate tools like JMeter, LoadRunner or Gatling. In this blog, we'll explore how Postman a tool widely used for API development and functional testing offers a built-in performance testing feature that simplifies this process.
What is API Performance Testing:
API performance testing is a process of validating and measuring the performance and responsiveness of an API under various conditions and loads. The goal is testing an API to different levels of stress, load and concurrency to assess its ability to handle those scenarios effectively.
By performing performance testing we can find out:
Whether the API have the ability to handle increasing traffic?
How is the response time affected when multiple users are sending the requests at the same time?
Will the API be responsive under heavy load?
How Postman supports APIs performance testing:
Postman includes built-in features for testing the performance of API using the existing requests within a collection. Here, we will explore two essential features supported by Postman.
Simulated Load Testing:
Leveraging Postman by simulating load with multiple parallel virtual users and send requests at the same time. Virtual users act like real users by sending requests to the API simultaneously. When many virtual users send the same set of requests at once, it helps assess how the API performs under heavy load. The parameters used to configure the performance test are,
Number of simulated users
Test Duration
Ramp up time
Real Time Metrics:
As test runs, Postman enables real- time visualization of performance metrics, such as
Response Time
Throughput (requests per second)
Error Rate
Latency percentiles.
Setting up the load to simulate real world traffic:
The following parameters can be specified to simulate realistic load conditions,
Virtual users: The total number of users executing the requests concurrently during tests.
Test duration: The total run time in minutes that the performance test will run.
Load profile: Describes how the number of virtual users changes over the time. There are four types of load profiles
1. Fixed - Fixed load profile maintains the constant number of virtual users for the entire test duration.

Ramp up - Ramp-up load profile gradually adds more virtual users over time. The test starts with few users, gradually adds more users over time and then keeps a steady number of users for the rest of the test. Each user runs all the requests sequentially. The Ramp-up load profile has an Initial load field determines the starting number of virtual users.

Spike - Spike load profile is to test the performance of an API during sudden increase of virtual users. It is mainly to verify the sustainability of an API during sudden peaks. The Spike load profile contains Base load field, where the tests start with the base load of users and a sudden increase(spike) in users happens for a short time. After the spike, the test goes back to the base load.

Peak - Peak load profile is to test the performance of an API under maximum sustained load. The load gradually increases and holds peak for a period. It helps to check stability and performance at expected traffic peaks.

How to use Postman for performance testing:
Collection Runner can be used to set up performance test by following these steps:
Step 1: Select a collection which has a set of requests to perform CRUD operations, select an environment if any and click Run Collection.
Step 2: Select the Performance tab under Runner.
Note: Just like in functional testing, Postman also executes all associated Pre-request Scripts and Test Scripts during performance testing runs. For example, setting environment variables, generating tokens, or validating response data will be executed every time a virtual user sends a request during the test.
Step 3: Specify the load settings like Load profile, Virtual users, Test duration and click Run.
Step 4: Observe how fast the API responds and how many errors happen while the test is running in real time.
Step 5: After the test is complete, results will be available to identify any bottlenecks in response times and the number of requests the API can handle per second. This helps to identify where improvements are needed for better scalability and reliability.
Key metrics for Measuring API Performance:
Once the performance test starts, Postman immediately displays real time metrics which can be used to track the performance of an API. Postman will show the following metrics live as the test runs,
Response Time:
Response Time is the time taken for the API to respond to a request. It measures how quickly the API responds. A high response time could indicate performance bottlenecks
Average Response Time:
Average Response Time measures the overall time the API takes to respond to all requests sent by multiple virtual users running simultaneously. If the average is too high, it might mean that an API's performance is not efficient with high load.
Min/Max Response Time:
Min/Max Response Time measures the minimum and maximum time taken to respond to a request during the test. It helps to detect unusual response times that may impact the consistency and reliability of the API.
Throughput (Requests per second):
Throughput gives the number of requests successfully handled by the API each second. It measures the API's capacity to handle multiple users. A higher value indicates better scalability.
Error Rate:
The percentage of API requests that failed, may be due to signal crashes, authentication failures, or API overloads. Reducing errors makes the API tests more reliable.
Analyze Metrics at Request Level:
The request-level analysis provides detailed insights into each request made by virtual users. This helps to identify which request may have caused a problem, making it easier to troubleshoot and resolve issues. Performance metrics for individual requests can also be viewed by applying the request filter.

Analyzing Previous Performance Test Runs:
Past performance test runs can be accessed to review results, compare metrics over time, and analyze API behavior under different loads. It can be viewed as shown below,

Advantages of Built-in Performance Testing Feature in Postman:
Postman handles both functional and performance testing in the same interface. It acts like an All-in-One Tool.
No complex setup is required. With the existing Postman collections and environment, performance testing can be performed directly.
Built-in dashboards provide live insights into key metrics like average response time, error rate, and throughput.
Reduces the requirement for additional third-party performance testing tools and licensing fees.
Conclusion:
Postman's built-in performance testing features provide a powerful and user-friendly way to evaluate API reliability under load. Integrating functional and performance testing within a single tool enhances workflow efficiency and accelerates the debugging and optimization process.


