Let's talk about PV and concurrency, and how to calculate the number of web servers

Recently, I was chatting with a few friends about concurrency and server pressure. Many friends, do not know how to calculate concurrency? How many servers are appropriate to deploy? So, today, let's talk about PV and concurrency, as well as methods for calculating the number of web servers. These are my own ideas plus some online summaries. 

several concepts

Website traffic refers to the number of website visits, which is used to describe the number of users visiting the website and the number of pages viewed by users. Common statistical indicators include the number of independent users of the website, the total number of users (including repeat visitors), page views The number of page views per user, the average time a user spends on the site, etc.

Common measures of website traffic: Unique Visitors (UV) and Page Views (PV), which are generally measured and calculated on a daily basis.

Unique visitor (UV): Refers to the same visitor visiting the website multiple times within a certain time range, and only counts as one unique visitor.

Pageviews (PV): Refers to the number of page views or clicks within a certain time frame, which is counted once every time a user refreshes.

PV calculation bandwidth

There are two metrics to focus on when calculating bandwidth size: peak traffic and average page size.

for example:

Assuming the average daily PV of the website: 10w of visits, the average page size is 0.4M.

Website bandwidth = 10w / (24 * 60 * 60) * 0.4M * 8 = 3.7 Mbps

The specific calculation formula is: website bandwidth = PV / statistical time (converted to S) * average page size (in KB) * 8

During the actual operation of the website, our website must maintain normal access during peak traffic. Assuming that the peak traffic is 5 times the average traffic, according to this calculation, the actual required bandwidth is about 3.7 Mbps * 5 = 18.5 Mbps .

PS

1. The unit of byte is Byte, and the unit of bandwidth is bit, 1Byte=8bit, so when converting to bandwidth, multiply by 8.

2. In actual operation, due to reasons such as cache, CDN, and different traffic volume during the day and night, this is the algorithm under absolute conditions.

 

PV and concurrency

The specific calculation formula is: number of concurrent connections = PV / statistical time * number of page derived connections * http response time * factor / number of web servers;

explain:

The number of page derived connections: a page request, there will be several http connections, such as external css, js, pictures, etc., this depends on the actual situation.

http response time: the average response time of an http request, 1 second or less can be used.

Factor: the multiple of peak flow and average flow, generally use 5, it is best to calculate it according to the actual situation.

example:

10PV of concurrent connections: (100000PV / 86400 seconds * 50 derived connections * 1 second response * 5 times the peak) / 1 web server = 289 concurrent connections

Therefore, if we can test the number of concurrent connections and daily pv of a single machine, then we can also estimate the number of servers that need web.

There is also a set of methods for calculating pv and the number of web servers required by single-machine QPS. At present, some companies use this calculation method, but in fact, the calculation principles are similar.

QPS, PV and the calculation formula of the number of machines to be deployed (transfer)

Terminology Description: 

QPS = req/sec = requests/sec 

[How QPS calculates PV and machines] 

QPS statistics method [generally use http_load for statistics] 

QPS = total number of requests / (total number of processes * request time) 

QPS: The number of successful requests to the server per second for a single process 

PV calculation for a single server per day 

Formula 1: Total PV per day = QPS * 3600 * 6 

Formula 2: Total PV per day = QPS * 3600 * 8 

server computing 

Number of servers = (Total PV per day / Total PV per server per day) 

[Peak QPS and machine calculation formula] 

Principle: 80% of daily visits are concentrated in 20% of the time, and this 20% time is called peak time 

Formula: (Total PV * 80% ) / (Seconds per day * 20% ) = Peak Time Requests Per Second (QPS) 

Machines: Peak time QPS per second / QPS per machine = required machine 

Example: 300w PV per day on a single machine, how many QPS does this machine need? 

( 3000000 * 0.8 ) / (86400 *0.2 ) = 139 (QPS) 

Example: If the QPS of a machine is 58, how many machines are needed to support it? 

139 / 58 = 3

Guess you like

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