[Go] talk about PV and concurrency, and how to calculate the number of Web servers

Source: Internet
Author: User

Recently and a few friends, chatting to concurrency and server stress issues. Many friends, do not know how to calculate concurrency? How many servers are appropriate to deploy? So, let's talk about it today. PV and concurrency, as well as how to calculate the number of Web servers. These are their own ideas plus some online summary, if not, welcome to shoot bricks.

Several concepts

Website traffic refers to the number of visits to the site, to describe how many users have visited the website and the number of pages viewed by the user, commonly used statistical indicators include the number of independent users of the site, the total number of users (including repeat visitors), the number of page views, the number of page views per user, the average time spent on the site, etc.

Common metrics for website visits: Independent visitors (UV) and integrated Views (PV), usually measured and calculated in days.

Independent Visitor (UV): The same visitor visits the site multiple times within a certain time frame, calculated as 1 independent visitors.

Comprehensive View Amount (PV): Refers to the amount of page views or clicks within a certain time frame, and the user is counted once per refresh.

PV COMPUTE Bandwidth

Calculating the bandwidth size requires two metrics: peak traffic and the average size of the page.

As an example:

Assuming the average daily pv:10w of the site, the average size of the page is 0.4 M.

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

The specific calculation formula is: Website bandwidth = PV/Statistical time (conversion to s) * Average page size (in KB) * 8

In the actual site operation, our site must be in peak traffic to maintain normal access, assuming that peak traffic is 5 times times the average traffic, according to this calculation, the actual required bandwidth of about 3.7 Mbps * 5=18.5 Mbps.

PS:

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

2. In practice, this is an absolute algorithm, due to the fact that the cache, CDN, and day-night traffic are different.

PV and concurrency

The specific calculation formula is: Number of concurrent connections = PV/Statistics time * page Derived connections * HTTP response time * Factor/number of Web servers;

Explain:

Page derivative connections: A page request, there will be several times the HTTP connection, such as external CSS, JS, pictures, etc., according to the actual situation.

HTTP response time: The average response time for an HTTP request, which can be used for 1 seconds or less.

Factor: The peak flow and the average flow of multiples, generally use 5, preferably according to the actual situation calculated.

Example:

Concurrent connections for 10PV: (100000pv/86400 sec * 50 Derived connections * 1 seconds in response * 5 times times Peak)/1 Web server = 289 Concurrent connections

So, if we can test the number of concurrent connections, and the number of PV in a single machine, then we can also estimate the number of servers that need the Web.

There's also a set of methods for calculating PV and the number of Web servers required by a single-machine QPS, and some companies are using this method of computing, but the principle of calculation is similar.

QPS, PV, and number of machines to be deployed (RPM)

Term Description:

QPS = REQ/SEC = Number of Requests/sec

"The way the QPS calculates PV and machines"

QPS statistics [general use of http_load statistics]

QPS = Total Requests/(total number of processes * Request time)

QPS: Number of successful requests per second of a single process server

Single server PV calculation per day

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

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

Server computing

Number of servers = (total PV per day/single server total PV per day)

"Peak QPS and machine calculation formula"

Principle: 80% of visits per day are concentrated in 20% of the time, 20% times called peak time

Formula: (Total PV number * 80%)/(number of seconds per day * 20%) = Peak Time requests per second (QPS)

Machine: Peak time per second QPS/single machine for QPS = Required machine

Example: 300w PV per day on a single machine, how much 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

[Go] talk about PV and concurrency, and how to calculate the number of Web servers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.