The Barbershop model is a good way to understand many of the concepts and theories of performance testing, as well as some of the problems encountered during testing
Abstract concepts are concretized, and the performance and concurrent processing of the system are understood through the barbershop model
I. Model hypothesis
In this barbershop, the following assumptions are made beforehand:
- There are three barbers in the barbershop
- Each barber takes an hour to cut a hair
- The amount of waiting time and haircut time that customers can tolerate is three hours per visit, and the longer the waiting time, the lower the satisfaction of customers. If they don’t get their hair cut in three hours, our clients will leave in a heartbeat
Second, scene construction
2.1 scenario 1
- There was only one customer in the barbershop
He has a barber to help him, and two others to wait or do chores. One hour later, the two customers cut their hair and went out. In this one hour, the barbershop only served one customer, who spent one hour on this haircut
- There are two customers in the barbershop
At the same time, there are two barbers serving customers, and another is waiting or doing chores. An hour later, two customers cut their hair and go out. In this hour, the whole barbershop served two customers, and each of them spent an hour in cutting their hair
- There were three customers in the barbershop at once
There are three barbers serving customers at the same time. One hour later, three customers cut their hair and went out. In this one hour, the whole barbershop served three customers, and each of them spent an hour in cutting their hair
Scene summary: When the number of customers served at the barber shop increases from 1 to 3, the overall working efficiency of the barber shop increases with the increase of customers, and the time spent by each customer in the barber shop does not extend
Can assume that, of course, when only one customer and two customers, free of the barber can help to fetch and carry, make other barber’s work efficiency, and make the cutting time of each customer is less than 1 hour But even if according to this hypothesis, although the increase in the number of customers, the service time of each customer, But this time is always controlled within the acceptable range of customers, and customers do not need to wait
2.2 scenario 2
As the barbershop’s business got better and better, there were more customers and new scenes appeared
Suppose you have A customer A, B, C just entered the barber shop to cut hair, push the door and came in outside customer D, E, F for A, B, C three customers the first, so D, E, F three had to sitting on A bench waiting for 1 hours later, A, B, C three finished my hair cut away, each of them the cutting the time it takes for 1 hour. However, D, E, and F were not so lucky because they had to wait for A, B, and C to get their hair cut first, so they each spent two hours on the haircut — one hour waiting and one hour getting their hair cut
As can be seen from the above scene, A barber shop usually serves three customers per hour — A, B, and C for the first hour, D, E, and F for the second hour. But for customers D, E, and F, the “response time” is extended
2.3 scenario 3
Suppose the barbershop a customer to the nine, three of the 9 customers “response time” for 1 hour, there are three “response time” for 2 hours (wait for 1 hour + cut 1 hours), there are three “response time” for 3 hours (+ cut 1 hour waiting for 2 hours) – has already reached the user can endure limit. If we change the number of customers in this scenario to 10, we can already assume that one customer will eventually leave the barbershop because of the long response time
3. Performance model
How does the above scenario relate to performance testing?
- Utilization
Utilization of resources (including hardware and software resources)
- Throughput
Throughput (transactions per second)
- Response Time
The response time
- Number of Concurrent Users
The horizontal axis shows the increasing number of concurrent users from left to right
3.1 Stage Division
- At the start of
As the number of concurrent users increases, the resource usage and throughput increase correspondingly, but the response time does not change much
- Intermediate stage
When the number of concurrent users increases to a certain extent, the resource occupancy reaches saturation, and the throughput growth slows down or even stops, while the response time is further prolonged
- At the end of the stage
If the number of concurrent users continues to increase, the utilization of hardware and software resources continues to remain saturated but the throughput begins to decline, and the response time obviously exceeds the acceptable range of users, and eventually the users give up the request or even leave
3.2 Region Division
- Light Load
Lighter pressure
- Heavy Load
Heavier pressure
- Buckle Zone
The user can’t stand it and abandons the request
3.3 Derived Concepts
According to regional junction, two concepts are derived:
- Optimal number of concurrent users
The Optimum Number of Concurrent Users at The junction of The Optimum Number of Concurrent Users Light Load and Heavy Load
- Maximum number of concurrent users
The Maximum Number of Concurrent Users at The junction of The Heavy Load and Buckle Zone
3.4 Model Summary
- The load on the system is equal to the optimal number of concurrent users
The overall efficiency of the system is highest, no resources are wasted and users do not have to wait
- The system load is between the maximum number of concurrent users and the maximum number of concurrent users
The system can continue to work, but the user waits longer, satisfaction begins to decrease, and if the load continues, some users will eventually give up
- The system load exceeds the maximum number of concurrent users
Some users give up because of the long response times
3.5 Combination Scenario
- Three customers arrive every hour
The barbershop has the highest overall work efficiency, with 3 customers per hour being the best number of concurrent users
- Nine customers are arriving every hour
The first few hours of customers can tolerate, but as the number of customers to wait more and more, the waiting time becomes longer and longer, eventually some customers can not tolerate and leave, 9 customers per hour is the maximum number of concurrent users
Along with the increasing Numbers of customers in a barber shop and the barber the extension of working hours, the barber will gradually produce fatigue, will also spend some time to clean up the environment and to keep order, these factors will eventually lead to the barber’s working efficiency increased as the number of customers and reduced gradually with the extension of, in the end may be 1.5 hours even 2 hours to finish cut a hair
Iv. Users
Further elaborate on the optimal and maximum number of concurrent users
For a certain system under test, in a specific software and hardware environment, its optimal and maximum concurrent users are objective existence
4.1 Optimal Number of Users
Suppose that a system is the best number of concurrent users of x, once the concurrency value more than the value, the system throughput and response time will inevitably If the system load is greater than the number for a long time, will inevitably lead to user satisfaction to reduce and eventually reach the point of a kind of unbearable Ensure optimum number of concurrent users should be greater than the average load of the system
Consider: When a system needs to be stressed for a long time (e.g. 7*24) to verify the reliability or stability of the system, the number of concurrent users used should be equal to or less than the optimal number of concurrent users.
4.2 Maximum Number of Users
Timeout limit This timeout limit is derived from performance requirements
- The response time of a system should be less than 5s at a certain level of load
- At a certain level of load, the response time of an underlying microservice should be less than 60ms
Don’t put the maximum number of users node because customers can’t stand and the number of customers when they leave the store as a barber’s maximum number of concurrent users, because the customer was before 3 hours to arrive, that is to say, the number of customers within three hours before the barber is the maximum number of concurrent users we are looking for the customer to leave just a start, More customers are likely to leave later, fed up with the long wait times
User capacity Before the response time reaches the maximum that the user can tolerate, it is possible to have user request failure. Take the barber shop model as an example: If the barbershop can only accommodate six customers, all seven customers will get their hair cut in a tolerable amount of time, but one customer will have to go home and come back another day because of the limited capacity of the barbershop
For a system, we should ensure that:
- The maximum number of concurrent users must be greater than the average system load
- The maximum number of concurrent users must be greater than the peak load required by the system
5. Expand your thinking
How do extensions to the Barber shop model relate to aspects such as performance testing and performance solutions
5.1 Extended Scenario 1
- scenario
In some barbershops, regular customers are very familiar with the barber, and the barber knows the customer’s idea without spending time in communication. Moreover, the barber is familiar with the shape of the customer’s head, so he can finish a haircut faster
- system
Analogous to a system cache
5.2 Extended Scenario 2
- scenario
Problem: barber shop cut is not just a business, also provide a perm hair color, etc, with the increase of business of perming and coloring, the barber services a customer time 1 hour could exceed the standard, some customers queuing time will be longer than originally expected, and eventually they unable to bear and leave to solve: The barbers decided to divide their jobs, with two haircuts and one perm and color
- system
The division of labor of barbers is the division of labor for the server to handle different requests. The B/S system is an epitome. With the increase of user traffic and the enrichment of functions, the overall architecture of the system needs to be changed accordingly to meet the needs of users
5.3 Extended Scenario 3
- scenario
Problem: The barbershop business is getting better and better. The number of barbers and the appearance of the barbershop can no longer meet the needs of customers
- system
A CPU is like a barber, so a server has several cpus. When the service expands, more cpus are needed, and when the service grows, more servers are needed
5.4 Extended Scenario 4
- scenario
Problem: barber shop business becomes extremely popular, two stores are unable to meet the needs of increase in the number of customers, and some customers began to reflect it was too far to the barbershop, arrived again because of too much perming and coloring people wait too long to solve: the barber’s boss understand perming and coloring of your income should be far higher than the haircut, so decided to change strategy
- In the vicinity of several large community rented small shops to open branches, full-time hair business
- Set up flagship store in downtown busy road, specialized for perm, hair coloring customers, as well as VIP customers service
- Add 800 number, when customers want to cut hair to call, and by the service personnel according to the customer living place, it will be directed to the nearest branch
- system
- When the business reaches a certain level, it is divided into dedicated servers to provide specific services
- Disassemble functional modules according to performance requirements of different users
- The phone is the equivalent of a DNS server, which is transferred to a different server for different submission services