1 Web front-end optimization
- Use Site static and dynamic separation architecture;
- Reduce
Http
transmission requestsCSS/JS
combined transport, compressionJS
,CSS
techniques; - Use the browser cache static resources, reduce server stress;
- Use
CDN
content distribution, reduce broadband transmission, access userIP
assigned to the nearest server access; - Front and rear ends separation techniques.
2 combat CDN
content distribution
2.1 DNS
domain name resolution process
DNS
That Domain Name System
is the meaning of domain name resolution services. It is the role of the Internet: the domain name can be converted into a network to identify the IP address. People used to remember domain name, but only recognize each other between the machine IP addresses, domain names and IP addresses between one to one conversion work between them as domain name resolution, domain name resolution needs to be done by a dedicated DNS server, the entire the process is automatic.
Common DNS
resolution service providers are: Ali cloud resolution, resolve million net, DNSPod, the new network parsing, Route53 (AWS), Dyn, Cloudflare and so on.
2.2 traditional way of requests for static resources
If you do not use the CDN
server, then go is HTTP
requested, in essence Request
, and Response
.
Traditional way architecture drawbacks:
- Pressure bandwidth of the transmission;
- Because all gathered to all users accessing a server on the same area, we can not ensure the overall system availability;
- Because if the client and server-side transmission distance farther, then broadband transmission is very resource intensive, resulting in poor user experience very slow response.
2.2.1 What is CDN
CDN
Acceleration means that plus a caching mechanism, dynamic access between the user and our server IP
address based on geographical location, allowing users to the nearest server access.
CDN
Stands Content Delivery Network
, that is 内容分发网络
.
CDN
It is a set of geographically distributed across multiple Web servers, for more effectively publish content to the user, while optimizing performance, will be selected based on distance.
CDN
The system can in real time the overall information connected to the network traffic and each node, the load conditions and the user's distance and response time of the user redirects the request from the user nearest service node, which purpose is to enable the user to the nearest access request data and solve network congestion, improve access speed, solve network bandwidth is small, user access to large, uneven distribution network causes the problem of slow access speed.
Since the CDN
deployment of the network operator's room, these carriers and a provider of end-user network, and the first hop of user requests to reach the CDN
server, when the CDN
server buffers the data requested by the user, can then be from CDN
directly back to the browser device, it is possible to improve the access speed.
CDN
The ability to cache JavaScript
scripts, CSS
stylesheets, images, icons, Flash
and other static resource files (not including the html page), the frequency of these static resource access text files is very high, it will cache CDN
can greatly improve the speed of access to the site, but due to CDN
the deployment of in the network operator's room, so they are rarely used in the general website CDN
acceleration.
2.2.2 CDN
content distribution principle
- To provide users with access to the domain name to the browser;
- The browser calls the DNS database of the domain name resolution, because the
CDN
domain name resolution process has been adjusted, so parsing libraries generally get is the domain name correspondingCNAME
records, in order to get the actualIP
address, the browser needs again to obtain theCNAME
domain name resolved to get the actualIP
address; in this process, using the global load balancingDNS
resolved, such as geographic location information corresponding to resolveIP
the address, so that the user can access the nearest; - The parsed
CDN
cache serverIP
address, browser actually get in theIP
future address, issues an access request to a cache server; - The browser cache server provides the domain name to be accessed by
Cache
an internal dedicatedDNS
obtained actual parsing the domainIP
address, then the cache server of this actualIP
commit access request address; - From the actual cache server
IP
after the address contents have been, on the one hand be stored locally, for later use, on the other hand returns the acquired data to the client, the completion of a data service process; - It is displayed after the data returned by the client to obtain the server cache the entire browser and completes the data request procedure.
2.2.3 Ali cloud environment to build combat CDN
content distribution
step:
1, create a cloud Ali CDN
Address
2. Go to parse CNAME
2.3 Glossary
2.3.1 CNAME 记录
CNAME
I.e. aliases (Canonical Name); it can be used to resolve a domain to another domain.
When the DNS system at the time of the query name CNAME left, will shift to the right of the name CNAME further inquiries, has been traced to the last name of the PTR or A, will respond to inquiries after the success, or failure.
For example, you have a lot of information stored on a server, you use docs.example.com
to access these resources, but hopes to documents.example.com
be able to have access to these resources, then you can in your DNS
add a resolution service provider CNAME
records, the documents.example.com
point docs.example.com
, the article added after the CNAME record, all access documents.example.com
requests will be to docs.example.com
get the same content.
2.3.2 CNAME 域名
Access CDN
when, after Ali cloud console finished adding speed up domain, you'll get a domain name CNAME Ali cloud CDN assigned to you, (the CNAME domain name must be *.*kunlun*.com
), you will need to resolve service providers add a CNAME record to your DNS, will accelerate their domain name to point to this *.*kunlun*.com
the CNAME domain name, the domain name so that all requests will Ali cloud will turn the CDN nodes to achieve accelerated results.