Best practices for sending batch requests using Postman

Table of contents

background

Send in bulk?

origin

think

Postman batch sending interface

Create collections and interfaces

Batch sending interface

How to obtain information


background

I have written several interfaces recently:

  • Get the interface of books
  • Get the interface of likes
  • Get the interface of collections

But I'm still worried, because are these interfaces stable? Are there any hidden dangers after going online? So I want to do a batch sending interface simulation~

But if you want to implement the batch sending interface, there must be a condition for batch sending .

Send in bulk?

origin

When we write an interface and deploy it, we must consider one issue:

  • Does your product get a lot of traffic?
  • Can the interface and server you write handle heavy traffic scenarios?

Compare your product to have many users sending requests in large batches at the same time~

For example, if the company has only one entrance, can 1w employees pass through it in 10 seconds ?

That's definitely not possible, so what should we do? Then it depends on how you optimize the subway entrance.

think

But no matter how much you optimize, you can't deploy it online right away, right? You must make a standardized multi-interface batch sending before going online to see if the interface you wrote and your server can withstand such pressure.

Postman batch sending interface

Create collections and interfaces

First, create a collection and add it one by one

  • Get the interface of books
  • Get the interface of likes
  • Get the interface of collections

Then to be on the safe side, add assertion verification in Test

pm.test('返回数据是 books', () => { console.log(pm.response.text()) pm.expect(pm.response.text()).to.include('books') })

Then click Send, we will find that the interface is sent successfully, and the assertion check also passes~~

Batch sending interface

But in fact, sending via a single interface is not what we want. What we want is:

  • Batch sending interface
  • Send frequently

So you need to use Postman’s Runner function

Then do the following:

  • Step 1: Drag the entire collection into the test area
  • Step 2: Set the number of concurrencies
  • Step 3: Set the delay for each concurrency
  • Step 4: Click the button for batch sending interface

And get the result report:


How to obtain information

【Message 777】

Friends who want to get the source code and other tutorial materials, please like + comment + collect , three times in a row!

After three consecutive rounds , I will send you private messages one by one in the comment area~

Guess you like

Origin blog.csdn.net/GDYY3721/article/details/132232700