30.1 Automating Tests with Load Drivers | 使用负载工具实现自动化测试
Problem
You need to automate your tests with a load driver to gain consis‐
tency and repeatability in your testing.
问题
使用负载测试工具实现自动化测试
Solution
Use an HTTP load testing tool such as Apache JMeter, Locust,
Gatling, or whatever your team has standardized on. Create a con‐
figuration for your load-testing tool that runs a comprehensive test
on your web application. Run your test against your service. Review
the metrics collected from the run to establish a baseline. Slowly
ramp up the emulated user concurrency to mimic typical produc‐
tion usage and identify points of improvement. Tune NGINX and
repeat this process until you achieve your desired results.
解决方案
使用 HTTP 负载测试工具:如 Apache JMeter/ Locust/ Gatling/或团队
自研的负载工具。为测试定制测试配置,并对服务器进行全面测试,基于
测试结果量化性能指标;之后,逐步增加用户数增加并发量,以模拟生产
环境真实请求,找出性能瓶颈优化;如此反复,直至达到项目的预期性能。
Discussion
Using an automated testing tool to define your test gives you a con‐
sistent test to build metrics off of when tuning NGINX. You must be
able to repeat your test and measure performance gains or losses to
conduct science. Running a test before making any tweaks to the
NGINX configuration to establish a baseline gives you a basis to
work from so that you can measure if your configuration change has
improved performance or not. Measuring for each change made will
help you identify where your performance enhancements come
from.
结论
使用自动化的测试工具来定义您的测试,可以让您通过一个一致的测试来
找出对 NGINX 进行调优的基准。性能测试必须是可重复的,通过对性能测
试结果进行科学分析。在对 NGINX 配置进行优化前,需对服务器进行测试
确定标准,这样,才能确定之后的配置优化是否实现了性能的优化。对每个
配置优化进行度量,将帮助您确定性能得以提升的根源。