PV model

Do you want to build a website that can withstand 5 million PV/day? What is the concept of 5 million PV? How many requests per second does the server have to handle? What if it was calculated?

1. What is PV

      PV is short for page view. PV refers to the number of visits to a page. Every time a page is opened or refreshed , it is considered a pv. 
2. Computational Model

     The number of requests processed by each server per second = ((80% * total PV volume) / (24 hours * 60 minutes * 60 seconds * 40%)) / number of servers. The key parameters are 80% and 40%. Indicates that 80% of requests occur 40% of the day . 40% of the 24 hours is 9.6 hours, and 80% of the requests occur in 9.6 hours a day (very suitable for Internet applications, with more requests during the day and less requests at night).

Note: PV measurement standard: (1) Number of requests processed per unit time: According to laboratory conditions, the peak number of requests that a single server can process per second is 500; (2) The number of transactions per second;

The result of a simple calculation:
((80%*5 million)/(24 hours*60 minutes*60 seconds*40%))/1 = 115.7 requests/second 
((80%*1 million)/(24 hours*60 minutes*60seconds*40%))/1 = 23.1 requests/second 
Preliminary conclusion: 
      Now we have a standard when we are doing stress tests. If your server can handle 115.7 requests per second, it can withstand 5 million PV/per day. If your server can handle 23.1 requests per second, it can withstand 1 million PV/day;

Leave enough margin:

      The above number of requests is evenly distributed in the 9.6 hours of the day, but the actual situation is not so evenly distributed, there will be peaks and valleys. In order to cope with the peak hours, there should be some leeway, at least x2 times, and x3 times is not an exaggeration.

     115.7 requests/sec * 2 times = 231.4 requests/sec

     115.7 requests/sec * 3 times = 347.1 requests/sec

     23.1 requests/sec * 2 times = 46.2 requests/sec

     23.1 requests/sec * 3 times = 69.3 requests/sec

final conclusion:

     If your server can handle 231.4--347.1 requests per second per second , it can handle an average of 5 million PV per day.

     If your server can handle 46.2--69.3 requests per second, it can handle an average of 1 million PV/day .

illustrate:

     Here we explain N requests per second, which is QPS. Because what I care about is the ability of the application to handle the business. 

practical experience:

1. According to actual experience, two rack-mounted servers with conventional configuration are used, and the configuration is very common, such as a 4-core CPU + 4G memory + server SAS hard disk .

2. Personally, I think that Intel's CPU is superior to AMD 's CPU in the field of server CPU . If there is any objection, please object. I say that I am arbitrary. Don't believe too much in AMD's advertisements. The easiest way to compare CPU performance is to compare price, not frequency and core count. The performance of the same price is similar.

3、硬盘的性能很重要,由其是数据库服务器。一般的服务器都配1.5万转的SAS硬盘,高级一点的可以配SSD固态硬盘,性能会更好。最最最最重要的指标是“随机读写性能”而不是“顺序读写性能”。(本例还是配置最常见的1.5万转的SAS硬盘吧

4、一台服务器跑Tomcat运行j2ee程序,一台服务器跑MySql数据库,程序写的中等水平(这个真的不好量化),是论坛类型的应用(总有回帖,不太容易做缓存,也无法静态化)。

5、以上软硬件情况下,是可以承受100万PV/每天的。(已留有余量应对突然的访问高峰)

注意机房的网络带宽:

     有人说以上条件我都满足了,但实际性能还是达不到目标。这时请注意你对外的网络的带宽,在国内服务器便宜但带宽很贵,很可能你在机房是与大家共享一条100M的光纤,实际每个人可分到2M左右带宽。再好一点5M,再好一点双线机房10M独享,这已经很贵了(北京价格)。

     一天总流量:每个页面20k字节*100万个页面/1024=19531M字节=19G字节,19531M/9.6小时=2034M/小时=578K字节/s   如果请求是均匀分布的,需要5M640K字节带宽(5Mb=640KB 注意大小写,b是位,B是字节,差了8倍),但所有请求不可能是均匀分布的,当有高峰时5M带宽一定不够,X2倍就是10M带宽。10M带宽基本可以满足要求。

     以上是假设每个页面20k字节,基本不包含图片,要是包含图片就更大了,10M带宽也不能满足要求了。你自已计算吧。

附:性能测试基本概念 --------------------------------------------------------------------------------------- 
基本概念: 
Throughput(吞吐量):按照常规理解网络吞吐量表示在单位时间内通过网卡数据量之和,其中即包括本机网卡发送出去的数据量也包括本机网卡接收到的数据量。 一个100Mb(位)的双工网卡,最大发送数据的速度是12.5M字节/s , 最大接收数据的速度是12.5M字节/s, 可以 同时 收发 数据。 并发用户数:是同时执行操作的用户(线程数)。 响应时间:从请求发出到收到响应花费的时间 。

QPS - Queries Per Second  每秒处理的查询数(如果是数据库,就相当于读取);

TPS - Transactions Per Second  每秒处理的事务数(如果是数据库,就相当于写入、修改) ;

IOPS,每秒磁盘进行的I/O操作次数
例如对某个数据库测试,分开两次测QPS与TPS。 QPS(读取)值总是高于TPS(写、改),并且有倍率关系,因为:

1、数据库对查询可能有缓存;

2、机械硬盘或SSD硬盘的读就是比写快;

--------------------------------------------------------------------------------------- 
loadrunner测试参数说明: 
响应时间: 
取90%值,如果把响应时间从小到大顺序排序,那么90%的请求的响应时间在这个范围之内。重要。 
每秒点击数 :hits per Second,每秒钟向服务器提交请求的数量。 
TPS: Transaction per Second ,每秒事务数,一个事务是指一个客户机向服务器发送请求然后服务器做出反应的过程 
Throughput(吞吐量): Loadrunner记录的Throughput是接收到服务器返回的所有字节数之和,与本地发出的字节数无关。 
Throughput/Sec: 每秒的吞吐量。 
对于BS架构的一般分析:响应时间、点击率、吞吐量、TPS(每秒事务数)。 
对于CS架构的一般分析 TPS(每秒事务数) 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326524760&siteId=291194637