background
I recently wrote several interfaces:
- Get the interface of books
- Get the interface of likes
- Get the interface of collections
But I am still worried, because are these interfaces stable or unstable? Are there any hidden dangers after going online? So I want to do a bulk send interface simulation~
But if you want to implement the batch sending interface, you must have a condition for batch sending .
Batch sending?
origin
When we write an interface and deploy it, we must consider a question:
- Do the products you make have a lot of traffic?
- Can the interfaces and servers you write handle scenarios with a large number of visits?
Compare your product with many users sending large batches of requests at the same time~
For example, the company has only one entrance, can 1w employees pass through within 10 seconds ?
That definitely won't work, so what should we do? Then it depends on how you optimize the subway entrance.
think
But no matter how you optimize it, you can't deploy it immediately, can you? Be sure to do a standardized multi-interface batch sending before going online , and see if the interface you wrote and your server can withstand such pressure
Postman batch sending interface
Create collections and interfaces
The first is to create a collection, and add in turn
- Get the interface of books
- Get the interface of likes
- Get the interface of collections
Then to be on the safe side, add an assertion check 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 test has passed~~
Batch sending interface
But in fact, sending by 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 and drop the entire collection into the testing area
- Step 2: Set the number of concurrency
- Step 3: Set the delay for each concurrency
- Step 4: Click the button to send the interface in batches
And get the result report:
Knowledge expansion:
Learn more Postman-related skills.