Test your API's performance in Postman

To ensure user success, it's not enough for your APIs to support the required functionality. Your APIs also need to handle the expected traffic volume. Performance testing enables you to simulate user traffic, so you can observe how your API behaves under load and identify any issues or bottlenecks.

About performance testing

Performance testing involves simulating real-world traffic with virtual users. As the virtual users make calls to your API, you can observe how your API behaves under the load. This enables you to evaluate how well your API meets expectations for response time, throughput, and availability under various conditions.

API performance testing can help you to do the following:

  • Simulate user traffic - Verify that your API can handle the expected traffic and check how your API responds to changes in load.

  • Locate bottlenecks - Identify issues such as latency and errors to ensure your API scales under load.

  • Improve the user experience - Optimize your API’s performance to create a better user experience.

In Postman, you can use the Collection Runner to test the performance of your API. Select a collection, and all of the virtual users loop through the requests in the collection in parallel. In the Collection Runner, you can set the duration of the test and the number of virtual users. You can also choose whether the number of virtual users is fixed for the duration of the test or ramps up and down during the test.

Collections icon View an example that shows how you can use Postman to set up and run performance tests for your API. To try out this collection template, select Performance testing.

Performance test setup in Postman

To get ready for performance testing your application in Postman, use the following framework:

  • The basic unit of testing is an API request. Each request tests a specific piece of functionality by calling an API endpoint. You can configure request authorization as needed. You can also send any required test data such as parameters, headers, and body data. Learn more about creating and sending requests.

  • Write scripts to add test logic to requests. For each request, you can write test scripts to check if the expected data is received when the request is sent. You can test and validate the response code, headers, body data, and more. Learn more about writing test scripts.

  • Organize suites of tests using collections. You can save multiple requests in a collection and organize them into categories. Collections enable you to run and rerun a group of tests in the order you choose. You can also upload data files to run tests multiple times using different data each time. Learn more about creating collections.

    You can also add a test suite to an API in Postman. Learn more at Test your API using test collections and CI tools.

  • Use scripts to build complex workflows. With scripts, you can process response data from one request and use it as an input in the next request to test data flow. You can also use scripts to dynamically control the order of requests. For example, send a request to create a user account, then send another request to get the new account and verify that it was created. Learn more about processing data and building workflows with scripts.

  • Run your tests in multiple environments. In Postman, environments are groups of related variables you can use in your requests. Environments enable you to reuse the same suite of tests in different contexts. For example, if your test and production setups require different URLs or configuration values, you can use Postman environments to switch between them. Learn more about working with environments and variables.

  • Simulate other systems with mock servers. You can test how your application interacts with other APIs and systems without having to connect to the actual resources. Instead, you can use Postman to set up a mock server that simulates the behavior of a real API server by accepting requests and returning responses. Learn more about setting up mock servers.

Run performance tests in Postman

Once you're ready, you can run your performance tests in Postman using the Collection Runner:

  1. Set up the collection you want to use for virtual users. The requests in the collection can simulate real-world user actions. During the performance test, each virtual user loops through the requests in the collection, in parallel with the other virtual users. Learn more about creating collections.

  2. Configure settings for the performance test. You can specify the duration of the test and the number of virtual users. You can also choose a profile to simulate different load conditions, and upload a data file to use unique data for each virtual user. Learn more about running a performance test in Postman.

  3. View real-time performance metrics and errors. While the test runs, you can view metrics such as throughput and response time. Once the test finishes, you can view error trends and get more details to help you debug problems. Learn more about viewing performance test metrics and debugging performance test errors.

Last modified: 2024/05/01