性能测试中Transactions Per Second与Requests Per Second的区别是什么?
Great question—this is a super common point of confusion in performance testing, especially since some sources toss around terms interchangeably. Let’s break this down clearly:
Key Differences Between TPS (Transactions Per Second) and RPS (Requests Per Second)
Requests Per Second (RPS)
- RPS is a low-level, technical metric that counts how many individual HTTP/API requests your system receives or processes every second. It doesn’t care about what the request is for or how it fits into a bigger business flow.
- For example: If you’re testing a simple API that returns user avatars, and it gets 1,200 GET requests every second, your RPS is 1,200. Each request is counted separately, even if multiple requests are part of the same user action.
Transactions Per Second (TPS)
- TPS is a business-focused metric that measures how many complete, end-to-end business transactions your system can handle per second. A single transaction often involves multiple individual requests working together to complete one user-facing action.
- For example: A "place order" transaction might involve 4 separate requests:
- Fetch current cart items
- Submit order details
- Deduct inventory
- Send confirmation email
- If your system completes 300 of these full "place order" flows every second, your TPS is 300—even though the total RPS for that scenario would be 300 * 4 = 1,200.
TPS as System Throughput
You mentioned some sources refer to TPS as System Throughput—that makes perfect sense. System throughput, from a business perspective, is all about how many complete, valuable operations your system can crank out. TPS directly captures that, so it’s often used interchangeably with system throughput in performance testing contexts.
Quick Example to Tie It All Together
Let’s say you’re testing a user login flow:
- Each login requires 2 requests: a POST to validate credentials, and a GET to load the user’s dashboard.
- If 400 users successfully log in every second:
- TPS = 400 (400 complete login transactions per second)
- RPS = 800 (400 * 2 individual requests per second)
When to Use Which?
- Use RPS when you’re debugging or optimizing a specific component (like a single API endpoint) and need to measure its raw request-handling capacity.
- Use TPS when you’re assessing overall system performance for real-world business scenarios (like peak shopping traffic) and need to know how many actual user actions your system can support.
内容的提问来源于stack exchange,提问作者Beklevir




