web project to handle high concurrent Solutions

A, CDN caches (upstream network request)

CDN is actually a method of distributed storage and backup of a resource. Address the distribution, bandwidth, server performance brings access latency problem for site acceleration, spike, on-demand, broadcast and other scenes. So that users can go to obtain the necessary content to address the Internet network congestion condition and improve the response speed and success rate of user access to the site.
Popular talk is talk about resources on the web server cache, when the user requests, at the request of upstream network resources can be distributed to users nearby. Without the need for all users to go to the web server with the requested resource.

  • Conventional web request processing flow
    1. To access the user enters in their own browser, Internet domain
    2. The browser request to the local DNS (Domain Name Server) server to resolve the domain name
    if the domain name cache has 3 local DNS server analysis results, the user's response to the resolution request directly to
    4. If there is no local DNS server caches analysis results on this domain, parsed recursively places a request to the DNS system overall, the results obtained after the response back to the browser
    5. browser name resolution result obtained, ip is the domain corresponding service apparatus
    6. the browser requests the content server
    7. the content server transmits a user request to the browser
    Here Insert Picture Description

  • After the introduction of CDN web request processing flow
    1. When the user clicks on the web page of the content URL, the system through the local DNS resolution, DNS will eventually resolve the domain name to the right of CDN dedicated DNS server CNAME points.
    2.CDN DNS server of the CDN global load balancing device IP returns the user
    3. The user load balancing equipment to the global CDN in heat content of URL access requests
    4.CDN global load balancing devices based on user IP address, and the user requests a URL, selecting a user belongs to region load balancing device allows the user to initiate a request to this device
    5. the area of the load balancing device will choose a cache server appropriate to provide users with services
    6. the user sends a request to the cache server, the cache server in response to a user request , the required user content to the user terminal
    7. If no content users want on this cache server, this server will request content from its cache on the server until the site dating back to the original content server pulled to the local
    Here Insert Picture Description

Two, nginx reverse proxy (intermediate layer network request)

nginx reverse proxy role:

  • Load Balancing:

Reverse proxy same content simultaneously proxy multiple application servers (such as tomcat), the client requests distributed to each application server and receive a response back to the client

  • Static and dynamic separation:

Using Nginx reverse proxy function to distribute requests: request all dynamic resources to application server, and requests for static resources (such as images, videos, CSS, JavaScript files, etc.) directly to the browser returned by Nginx

Common web site architecture design:
Here Insert Picture Description

  • Reverse proxy horizontal extension
    reverse proxy horizontal extension, by "polling DNS" to achieve: dns-server to resolve a domain name configured with a plurality of IP, DNS resolution request to each access dns-server, polls return these ip.
    When nginx become the bottleneck of time, as long as the increase in the number of servers, nginx new service deployment, add an external network ip, you can extend the performance reverse proxy layer, so theoretically infinitely high concurrency.
    Here Insert Picture Description
  • 站点层的水平扩展(分布式部署)
    站点层的水平扩展,是通过“nginx”实现的。通过修改nginx.conf,可以设置多个web后端。
    当web后端成为瓶颈的时候,只要增加服务器数量,新增web服务的部署,在nginx配置中配置上新的web后端,就能扩展站点层的性能,做到理论上的无限高并发。
    Here Insert Picture Description

三、站点的缓存技术(web应用层)

  • 1.数据缓存:
    对于不会频繁变动而访问量又比较大的数据可以做缓存处理,可以缓存到内存型数据库、客户端等。

  • 2.页面静态化:
    html静态化也是某些缓存策略使用的手段,对于系统中频繁使用数据库查询但是内容更新很小的应用,可以考虑使用html静态化来实现

  • 3.图片服务器分离:
    对于Web服务器来说,图片是最消耗资源的,于是我们有必要将图片与页面进行分离,这是基本上大型网站都会采用的策略,他们都有独立的、甚至很多台的图片服务器。

四、数据库

  • 1.硬件优化

  • 2.数据库读写分离、主从同步
    使用负载均衡实现,写操作都往主库上写,读操作往从服务器上读。

  • 3. sub-library sub-table
    sub-table way
    split horizon (row), split vertically (columns)
    sub-table scene
    A: According to experience, mysql table data generally reach one million level, the query efficiency will be very low.
    B: Some field values and a large table is rarely used. These fields can be isolated into a separate table, linked by key outside, such as test scores, we often focus on scores, the test does not care about the details.
    C: The big table open an order, order form, order pay table, order merchandise table.
    Horizontal component policy table
    sorted by time table: When the data has a strong effectiveness of such micro-blog data divided on a monthly basis.
    Press section part table: e.g. 1-1000000 user table with a table, one million to two million with a table.
    hash sub-table: the table is calculated by a data storing original target id or name in accordance with certain hash algorithm.

  • 4. Index Tuning
    will often be used less frequently and change the column using an index, the index is not possible, because the index must be recalculated when the data changes.

  • 5.SQL optimization
      1, try to avoid full table scans of hard to consider where and order by CV indexes on columns involved.
      2, should be avoided to a null value is determined fields in the where clause, will cause the engine to give up using the index and a full table scan.
      3, should be avoided in the where clause! = Or <> operator, otherwise the engine to give up using the index and a full table scan.
      4, like +% typically result in the double wildcard full table scan.

  • 6. Optimization field
    with reasonable accuracy using the field type and length of the control field and the like.
    For example, char varchar would not be able to meet

Guess you like

Origin blog.csdn.net/bocai_xiaodaidai/article/details/91039710