Professional Documents
Culture Documents
การทดสอบและประกันคุณภาพซอฟต์แวร์
Software Testing and Quality Assurance
Week 9
Performance Testing
Time Resource
Capacity
behavior Utilization
Degree to which the response and Degree to which the amounts and Degree to which the maximum limits of a product or system
processing times and throughput rates types of resources used by a parameter meet requirements (number of item that can be
of a product or system, when performing product or system, when performing stored, number of concurrent users, communication bandwidth,
its functions, meet requirements its functions, meet requirements throughput of transactions, size of database)
ระยะเวลาที่ใช้ในการตอบโต้กับผู้ใช้และที่ใช้ใน ปริมาณและประเภทของทรัพยากรที่ใช้โดย ขีดจากัดสูงสุดของพารามิเตอร์/ตัวแปรของผลิตภัณฑ์หรือระบบตรงกับความ
การประมวลผล ผลิตภัณฑ์หรือระบบเมื่อทาหน้าที่ตาม ต้องการ (จานวนรายการที่สามารถจัดเก็บได้ , จานวนผู้ใช้งานที่สามารถใช้
ข้อกาหนด พร้อมกัน , ขนาดของแบนด์วิดท์ที่ใช้ในการรับส่งข้อมูล , ขนาดของฐานข้อมูล)
Endurance Testing
Transaction Testing Load Testing Stress Testing Robustness Testing Scalability Testing
(Longevity/Soak)
Measure respond time, maximum limit to Go beyond limits for extended intervals how resilient the if the system is
identify bottle necks work (Volume / the system to (e.g. 24 hour 365 system will be to capable of providing
Concurrent users) looking for days per year) , negative input expected service
unexpected results/ repeat a transaction
more than once
Sample of volume/stress testing : Analogy of an air-traffic control system keeping track of 200 planes
• Volume test is to see what happened with 40,50, 100 and 200 planes
• Stress test will see what happens when 201st plane enters
Ref: https://www.javatpoint.com/performance-testing
SF332 Software Testing and Quality Assurance 8
Type of Performance Testing
Scalability testing
Checking the performance of an application by increasing or
decreasing the load in particular scales (no of a user) is
known as scalability testing. Scalability testing is divided into
two parts which are as follows:
Ref: https://www.javatpoint.com/performance-testing
SF332 Software Testing and Quality Assurance 9
Performance Testing Example
100 up users are increased continuously to check
Let us take one example where we will test the behavior of
the maximum load => upward scalability testing.
an application where the desired load is either less than
Pass
1000 or equal to 1000 users. 1000 users – 2.7/sec
100
•Scenario1: When we have the 1000 users as desired load, and the 2.7/sec is goal time, Load Testing
assume desired load is increased ( )
these scenarios will pass while performing the load test because in load testing, we will Pass
concentrate on the no. of users, and as per the requirement it is equal to 1000 user. 1100 users – 3.5/sec
100
•Scenario2: In the next scenario, we will increase the desired load by 100 users, and Stress Testing
assume desired load is again increased ( )
goal time will go up to 3.5\sec. This scenario will pass if we perform stress testing
because here, the actual load is greater than (1100) the desired load (1000). 100
1200 users – 3.5/sec
•Scenario3: In this, if we increase the desired load three times as
1200 → 3.5\sec: [it is not less than or equal to the desired load that's why it will Fail]
1300 → 4\sec: [it is not less than or equal to the desired load. i.e., Fail] 1300 users – 4/sec
100
1400 → Crashed
Ref: https://www.javatpoint.com/performance-testing
SF332 Software Testing and Quality Assurance 10
Agenda
Performance Efficiency
(ISO/IEC25010:2011)
Huge data transaction: If we have huge data means that n-number of the users using
6. Analysis result the application at the same time.
- Install tools
7. Identify the Bottleneck
- Access the test server
- Write script according to the test scenarios and run the tool
8. Re-run test
Ref: https://www.javatpoint.com/performance-testing
SF332 Software Testing and Quality Assurance 12
Performance Testing Process
1. Identify performance
scenarios - arrange the testing environment before the execution.
- manage the tools, other resources and distribute the load according to the
2. Plan and design
performance test script "Usage Pattern"
3. Configure the test - execute, validate, and monitor the test scripts
environment & distribute
the load
- check that the result meeting the goal in the given response time or not, and
4. Execute test scripts
the response time could be maximum, average, and minimum
- analyze the test result whether it meets with the response time or not.
5. Result
- identify the bottleneck (bug or performance issue).
6. Analysis result
And the bottleneck could occur because of these aspects like the problem in code, hardware issue
(hard disk, RAM Processor), network issues, and the software issue (operating system). And after
finding the bottleneck, we will perform tuning (fix or adjustment) to resolve this bottleneck.
7. Identify the Bottleneck
8. Re-run test
Ref: https://medium.com/@kit.kmutnb/performance-test-คืออะไร-ทาไปทาไมกันนะ
SF332 Software Testing and Quality Assurance 15
Performance Testing Process - Example
1. Identify performance
scenarios - เอา Scenario production มาทาการ Load Test ใน Environment ที่เตรียมไว้
2. Plan and design
performance test script - Monitor สรุป จากตัวอย่าง ถ้าเราใช้ Cloud environment ที่ spec ใหญ่
1) Response time ทุกเครื่อง แล้วถ้าเราสามารถลด spec production ได้ อาจจะเป็น
3. Configure the test
environment & distribute 2) Server resource 1/2 หรือ 3/4 ของ spec ที่ใช้อยู่ได้ก็สามารถ cost ในการเช่า
the load
3) TPS (Transaction per sec) Cloud ได้ในระดับนึงแล้ว
=> Result ที่ได้ออกมารับได้ไหม เช่น
4. Execute test scripts
ยกตัวอย่างสมมุติปกติเราใช้ Production server on cloud spec
กรณีที่ Result ออกมา Ok เป็น [ CPU 32 core , Mem 32 GB ] cost per month
5. Result Response time , Server resource , TPS => ok 200,000 baht
เราอาจจะ Retest อีกครั้งนึงเพื่อมั่นใจในการทดสอบ จากผลการ test เราสรุปได้ว่าเราใช้แค่ CPU 16 core Memory
6. Analysis result
16 GB cost per month อาจจะอยู่ที่ 120,000 baht จะทาให้
กรณีที่ Result ออกมา ไม่ Ok เห็นว่าสามารถลดค่าใช้จ่ายในการเช่า cloud ลงไปได้
เราก็ปรับขยาย Size ของ server ให้เพิ่มขึน้ แล้วทา
7. Identify the Bottleneck การ Load Test อีกครั้งไปจนเจอจุดที่รับได้ ข้อเสนอแนะเพิ่มเติม เมื่อปรับลด spec ที่ production จริงแล้ว
(Response time , server resource, TPS ได้ ในช่วงแรกควรมีการ monitor อย่างใกล้ชิด และ มี solution
8. Re-run test result ใกล้เคียงกับที่ Production เป็นอยู่) สารองในการแก้ปัญหาเผื่อไว้ด้วย
Ref: https://medium.com/@kit.kmutnb/performance-test-คืออะไร-ทาไปทาไมกันนะ
SF332 Software Testing and Quality Assurance 16
Performance Testing value
Throughout คืออะไร
Speed
- จานวน transaction/request ที่ถูกสร้างขึ้นหรือทางานได้ในช่วงเวลาการทดสอบหนึ่งๆ
- Formula: Throughout = จานวน request หรือ transaction
Resource Response จานวนเวลาการทางานรวม
Usage Time - ต้องกาหนดค่าเป้าหมายเสมอ เช่น
Performanc จานวนใน 1 วินาที นาที ชั่วโมง
e Test
Ref: https://www.somkiat.cc/performance-testing-about-throughput/
SF332 Software Testing and Quality Assurance 17
Difficulties - อุปสรรคในการทา Non-functional Testing
• Lack of performance objectives , Ambiguous/ immeasurable objective, Poor requirement /
ไม่มีวัตถุประสงค์หรือมีแต่กากวม ตรวจวัดไม่ได้ ข้อกาหนดไม่ชัดเจน
• Poor environment, use of test tools, unable to recreate customer environment
สภาพแวดล้อมไม่ดี การใช้เครื่องมือ การสร้างสภาพแวดล้อมให้ใกล้เคียงกับของลูกค้านั้นไม่ได้
• Testing cost exceeds system cost, uncontrolled workload on the system during performance testing /
ค่าใช้จ่าย
• Lack of specialized knowledge /ขาดผู้เชี่ยวชาญ
• Change of software could mean change in performance / ซอฟต์แวร์เปลี่ยน สมรรถนะซอฟต์แวร์ก็เปลี่ยน
• Lack of time for performance testing to be done well /ไม่มีเวลาจะทาให้ดี
https://www.radview.com/schedule-demo
SF332 Software Testing and Quality Assurance 20
JMeter
JMeter หรือชื่อจริงว่า Apache JMeter https://jmeter.apache.org/
สามารถทดสอบผ่าน protocol ต่าง ๆ ได้ดังนี้
•
Web - HTTP, HTTPS (Java, NodeJS, PHP, ASP.NET, …)
• SOAP / REST Webservices
• FTP
• Database via JDBC
• LDAP
• Message-oriented middleware (MOM) via JMS
• Mail - SMTP(S), POP3(S) and IMAP(S)
• Native commands or shell scripts
• TCP
• Java Objects
SF332 Software Testing and Quality Assurance 21
Jmeter Plugins
http://jmeter-plugins.org/
เพื่อเพิ่มฟีเจอร์ที่ช่วยอานวยความสะดวกในการทาการทดสอบด้วยดังนี้
•jp@gc — Stepping Thread Group: สาหรับใส่จานวนผู้ใช้จาลอง •jp@gc — Response Codes per Second:
ตั้งแต่จุดที่เริ่มต้นทดสอบและเพิ่ม/ลดจานวน thread ตามระยะเวลาได้ สาหรับตรวจสอบว่าระบบยังตอบสนองกลับมาเป็น 200 OK อยู่ ไม่ใช่
อย่างสะดวก ว่า response กลับมาเร็วแต่เป็น 500 Internal Server Error ฯลฯ
Ref: https://blog.maqe.com/load-testing-แบบลูกทุ่งด้วย-apache-jmeter-b9ac33476657
SF332 Software Testing and Quality Assurance 22
ตัวอย่างการทา Test Plan ด้วย jmeter
plugins jp@gc — Stepping Thread Group
Ref: https://blog.maqe.com/load-testing-แบบลูกทุ่งด้วย-apache-jmeter-b9ac33476657
SF332 Software Testing and Quality Assurance 27
Results - 2
กราฟ response time vs active threads
ระบบยังตอบสนองได้ดีจนถึง 400 active threads
ทดสอบอีกครั้งโดยเพิ่ม max. active threads ให้สูงขึ้นไปอีก
แสดงให้เห็นชัดเจนว่าด้วย configuration นี้ ระบบเริ่มไม่เสถียรตั้งแต่ 400 threads เป็นต้นไป
และแสดงให้เห็นด้วยว่า endpoint สีฟ้า ถึงแม้ response time จะสูสีกับคนอื่นมาตลอด
กลายเป็นตัวแรกที่แสดงอาการเมื่อโหลดสูงขึ้น
Ref: https://blog.maqe.com/load-testing-แบบลูกทุ่งด้วย-apache-jmeter-b9ac33476657
SF332 Software Testing and Quality Assurance 28
Results - 3
ระบบที่ทดสอบมี New Relic APM
(Application Performance
Monitoring), New Relic Servers
(Server Monitoring) และ Amazon
CloudWatch อยู่แล้ว เราจึงใช้อย่าง
เต็มที่เพื่อเก็บข้อมูลอื่นๆ ซึ่งทาให้เรา
เข้าใจระบบของเรามากขึ้นไปอีก
Ref: https://blog.maqe.com/load-testing-แบบลูกทุ่งด้วย-apache-jmeter-b9ac33476657
SF332 Software Testing and Quality Assurance 29
Results - 4
Amazon CloudWatch
ฝั่ง Database
ทาให้เราสังเกตการณ์โหลดบน
ฐานข้อมูลได้เช่นกัน
Ref: https://blog.maqe.com/load-testing-แบบลูกทุ่งด้วย-apache-jmeter-b9ac33476657
SF332 Software Testing and Quality Assurance 30
Example #1 - 1 เมื่อจานวน request สูงขึ้นมาเรื่อยๆ ค่าของ Throughput ก็เพิ่มมากขึ้นเช่นกัน
เมื่อไรก็ตามที่จานวน request และ จานวนการประมวลผลของระบบการทดสอบเริ่มนิง่
ก่อนการทดสอบ นั่นแสดงว่า ค่าของ Throughput ของระบบนั่นนิ่งหรือเสถียรแล้วเช่นกัน
ต้องทาการกาหนด หรือ สร้างจานวน request หรือ ผู้ใช้งานขึ้นมาก่อน
โดยจานวน request จะค่อยๆ ถูกสร้างขึ้นมาในรูปแบบ ramp up
คาอธิบาย
จะทาการสร้าง 100 request ภายใน 10 วินาที
ดังนั้น จะทาการสร้าง 10 request ต่อ 1 วินาทีนั่นเอง
Ref: https://www.somkiat.cc/performance-testing-about-throughput/
SF332 Software Testing and Quality Assurance 31
Example #1 - 2
ต้องการรู้ว่า ค่า Throughput จะสามารถเพิ่มขึ้นได้อีกหรือไม่ ? เช่น
- เพิ่มจานวน request ที่ส่งเข้ามาทดสอบระบบ เข้าคิวเพื่อรอทางานนานเกินไป เช่น CPU, database และ network เป็นต้น
ถ้าการเพิ่มจานวน request ทาให้ค่า Throughput ลดลงมา ส่งผลให้ response time สูงขึ้นมาก จนเกิด timeout
แสดงว่ามีส่วนใดส่วนหนึ่งในระบบงานเกิดปัญหาคอขวดมาแล้ว โดยจาเป็นต้องนาข้อมูลจากระบบ monitoring อื่นๆ
หรือนั่นคือ เกินขีดความสามารถของระบบในตอนนั้น เข้ามาพิจารณาด้วยนะครับ เช่น Monitoring server, access log เป็นต้น
เพื่อทาให้การวิเคราะห์ผล มีประสิทธิภาพและถูกต้องมากยิ่งขึ้น
รูปตัวอย่างแสดงระบบเกิดปัญหาคอขวดขึ้น
Ref: https://www.somkiat.cc/performance-testing-about-throughput/
SF332 Software Testing and Quality Assurance 32
Example #2 Load testing ก่อนและหลังทา code optimization
หลังจากที่ได้ผลลัพธ์ข้างต้น เราได้หยิบ 2 endpoints มาทา code optimization เพื่อให้โค๊ดใช้ทรัพยากรระบบลดลง
ปรากฎว่าการเปรียบเทียบผลลัพธ์ระหว่างก่อนและหลังการทา optimization ยิ่งมีความน่าสนใจเข้าไปอีก
Ref: https://www.somkiat.cc/performance-testing-about-throughput/
SF332 Software Testing and Quality Assurance 33
SF332 Software Testing and Quality Assurance 34