应用程序负载均衡器_如何对应用程序进行负载测试

应用程序负载均衡器

Frequently used terms in this article:

本文中的常用术语:

  • server: a single server where our application is running (or) a setup with multiple servers where our application is running.

    服务器: 运行我们的应用程序的单个服务器(或运行我们的应用程序的多个服务器的设置)。

  • client: a server that is used for firing/sending requests to our application.

    客户端: 用于向我们的应用触发/发送请求的服务器。

为什么要进行负载测试? (Why Load testing?)

Load testing is the process of putting load (user requests) and then checking the response of your application(under test). It is performed to check the system’s behavior under defined load and the peak load conditions.

负载测试是先进行负载(用户请求),然后检查您的应用程序响应(被测试)的过程。 它用于检查系统在定义的负载和峰值负载条件下的行为。

This testing usually helps in identifying -

此测试通常有助于确定-

  • The maximum operating capacity of an application.

    应用程序的最大操作容量。
  • Determine whether the current infrastructure is sufficient to run the application.

    确定当前基础结构是否足以运行该应用程序。
  • Sustainability of application for peak user load.

    峰值用户负载的应用程序可持续性。
  • Number of concurrent users that an application can support, and scalability to allow more users to access it.

    应用程序可以支持的并发用户数,以及允许更多用户访问它的可伸缩性。

有什么问题可以帮助我们解决? (What problems does it help us solve?)

Prevent the slow performance or even shutdown of the website during a high load.

防止在高负载下网站性能下降甚至关闭。

加载时间长 (Long load time)

The load test tells you how long it takes the pages to load at different traffic levels. You will get metrics on website speed during normal, peak, and overwhelming traffic load.

负载测试会告诉您页面在不同流量级别加载需要多长时间。 您将在正常,高峰和压倒性的流量负载下获得有关网站速度的指标。

响应时间短 (Poor response time)

Response time is a time a system takes to respond to a user’s requests. Load testing will help you to establish what causes delays in response time and optimize your system accordingly.

响应时间是系统响应用户请求所花费的时间。 负载测试将帮助您确定导致响应时间延迟的原因并相应地优化系统。

可伸缩性差 (Poor scalability)

Scalability is the capacity of the app to perform different tasks at the same time. As the number of your users grows, your app must be capable of processing a larger number of requests rapidly, without slowing down the overall performance. Load testing helps you determine whether your application scales when a load grows.

可扩展性是应用程序同时执行不同任务的能力。 随着用户数量的增长,您的应用必须能够快速处理大量请求,而又不降低整体性能。 负载测试可帮助您确定负载增加时是否可扩展应用程序。

瓶颈 (Bottlenecks)

There are a lot of types of performance bottlenecks that occur during software development and maintenance. These bottlenecks could be

在软件开发和维护过程中会发生很多类型的性能瓶颈。 这些瓶颈可能是

  • CPU utilization

    CPU利用率
  • Memory utilization

    内存利用率
  • Network utilization

    网络利用率
  • Software limitation

    软件限制
  • Disk usage

    磁盘使用情况
  • Hardware configuration of the system

    系统硬件配置

Load testing enables us in fixing these bottlenecks before the end-user faces them.

负载测试使我们能够在最终用户面对这些瓶颈之前解决这些瓶颈。

在发布之前确定问题 (Identify problems before the release)

  • The maximum operating capacity of an application.

    应用程序的最大操作容量。
  • Determine whether the current infrastructure is sufficient to run the application or not.

    确定当前基础结构是否足以运行该应用程序。
  • Response time of transactions during peak load.

    高峰负载期间事务的响应时间。
  • Number of concurrent users that an application can support, and scalability to allow more users to access it.

    应用程序可以支持的并发用户数,以及允许更多用户访问它的可伸缩性。
  • Performance of System components under various loads.

    在各种负载下系统组件的性能。
  • Performance of Database components under different loads.

    不同负载下数据库组件的性能。
  • Network delay between the client and the server.

    客户端和服务器之间的网络延迟。
  • Software design issues (HLD)

    软件设计问题(HLD)
  • Server configuration issues like web server, application server, database server, etc.

    服务器配置问题,例如Web服务器,应用程序服务器,数据库服务器等。
  • Hardware limitation issues like CPU maximization, memory limitations, network bottleneck, etc.

    硬件限制问题,例如CPU最大化,内存限制,网络瓶颈等。

负载测试指标 (Load testing metrics)

To estimate every aspect of your application’s performance and measure the success of load testing, the following metrics are used:

为了评估应用程序性能的各个方面并衡量负载测试的成功程度,使用了以下指标:

  • Latency: the amount of time it takes to send information from one point to another. Measure 90th Percentile Response Time (Industry practices)

    延迟: 从一个点到另一个点发送信息所花费的时间。 测量百分之九十的响应时间(行业惯例)

  • Request per second: number of requests sent to target server per second

    每秒请求数:每秒发送到目标服务器的请求数

  • Throughput: requests processed during the test (Requests per minute).

    吞吐量:测试期间处理的请求(每分钟的请求数)。

  • Errors percentage: percentage of errored requests compared to all requests.

    错误百分比:错误请求相对于所有请求的百分比。

  • CPU utilization: the sum of work handled by the CPU.

    CPU使用率: CPU处理的总和。

  • Memory utilization: the amount of RAM used by the application during testing.

    内存利用率:测试期间应用程序使用的RAM数量。

  • Network utilization: the amount of traffic on the network compared to the peak amount that the network can support.

    网络利用率: 与网络可以支持的峰值数量相比的网络流量。

  • Disk usage: the amount of storage needed for the application and its overall operation.

    磁盘使用率:应用程序及其整体操作所需的存储量。

Let the testing begin.

让测试开始。

客户端和服务器的配置 (Configuration of the client and server)

For the server, make a replica of your production environment:

对于服务器,制作生产环境的副本:

  • Extrapolating load test results is a very risky business. If you run the test on a one-gigabyte machine with two cores then what will results look like on a two-gigabyte machine with four cores? It’s practically impossible to know.

    推断负载测试结果是非常冒险的事情。 如果您在具有两个内核的1 GB机器上运行测试,那么在具有四个内核的2 GB机器上的结果将如何? 几乎是不可能知道的。
  • Therefore, you should replicate your production environment in every aspect: machine profile, configuration, database, network architecture, load balancer, firewalls, etc.

    因此,您应该在各个方面复制生产环境:机器配置文件,配置,数据库,网络体系结构,负载平衡器,防火墙等。
  • One method is to create complete images of production machines to be duplicated in your test or staging environment.

    一种方法是创建要在测试或登台环境中复制的生产机器的完整映像。

For the client, you can have any micro instance.

对于客户端,您可以具有任何微实例。

负载测试工具 (Tools for Load Testing)

I used Apache Bench for testing. You can use JMeter or any other tool in the market.

我使用Apache Bench进行测试。 您可以使用JMeter或市场上的任何其他工具。

Apache Bench — need to be installed on the client and it is used for sending requests to the server

Apache Bench —需要安装在客户端上,用于将请求发送到服务器

  • Start by installing Apache Bench (AB)

    首先安装Apache Bench(AB)
install apache2-utils

(or)

(要么)

yum install httpd-tools
  • Apache Bench (AB) usage -

    Apache Bench(AB)用法-
ab [options] [http[s]://]hostname[:port]/pathab -n [number_of_requests_to_perform] -c [number_of_multiple_requests_to_make [http[s]://]hostname[:port]/path
  • Example -

    范例-
ab -l -n 100 -c 10 -k -H “Accept-Encoding: gzip, deflate” http://www.example.com/
  • Sample Input -

    样本输入-
  • Sample output -

    样本输出-

用于衡量服务器性能的工具/命令 (Tools/commands used for measuring the server’s performance)

  1. top — command is used to show the Linux processes. It provides a dynamic real-time view of the running system.

    top —命令用于显示Linux进程。 它提供了正在运行的系统的动态实时视图。

  2. htop — similar to top, but a little upgraded version.

    htop-与top类似,但有一点升级。

  3. mpstat 1 — Used for processor related statistics and reports.

    mpstat 1-用于处理器相关的统计信息和报告。

  4. iostat 1 — Used for CPU statistics, input/output statistics for the block devices, partitions, and generate reports.

    iostat 1-用于CPU统计信息,块设备,分区的输入/输出统计信息以及生成报告。

  5. pidstat -G gunicorn 1 — Used for I/O, CPU, memory statistics for Linux processes and generates a report.

    pidstat -G gunicorn 1-用于Linux进程的I / O,CPU,内存统计信息并生成报告。

  6. docker stats <docker_name>

    docker统计信息<docker_name>

  7. Metric beat — set it up on your servers and you see the visualizations on Kibana.

    公制节拍 —在服务器上进行设置,然后在Kibana上看到可视化效果。

New Relic — used for measuring application performance or we can use any other APM tool.

New Relic-用于评估应用程序性能,或者我们可以使用任何其他APM工具。

You can get the following info -

您可以获得以下信息-

Response time of the api
Time spent in python (tested a python application)
Time spent in cache
Time spent in db
Time spent in external apis

You need to test with different combinations of APIs, read APIs, write APIs, etc.

您需要使用不同的API组合进行测试,读取API,写入API等。

负载测试报告 (Load Testing Report)

A load testing report should describe these points.

负载测试报告应描述这些要点。

  1. Product KPIs met?

    产品KPI达到了?
  2. Where is the bottleneck? Should provide areas where teams can invest to get better performance

    瓶颈在哪里? 应该提供团队可以投资以获得更好绩效的领域
  3. Is infrastructure sufficient?

    基础设施是否足够?
  4. Further, invest in performance tuning? Whether to take action on the insights from bottleneck discovery should be done before the go-live or not.

    进一步,投资于性能调整吗? 是否对瓶颈发现的见解采取行动,应该在上线之前进行。

发布前要讨论的事情 (Things to discuss before the release)

I was not able to do the formatting as per my expectation, so I moved it to a gist.

我无法按照我的期望进行格式化,因此我将其移至要点。

My investigation was done on a python application with flask (framework), gunicorn (app server), nginx (webserver), MySQL (database) & everything was deployed on AWS.

我的调查是在具有Flask(框架),gunicorn(应用服务器),nginx(网络服务器),MySQL(数据库)的python应用程序上完成的,所有内容均部署在AWS上。

After working through these points and taking the necessary steps, we can say that our load testing was a success.

在完成这些要点并采取必要的步骤之后,我们可以说我们的负载测试是成功的。

翻译自: https://medium.com/@aditya_misra5/how-to-load-test-your-application-c154a72968e2

应用程序负载均衡器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值