Layered construction of Web services

Source: Internet
Author: User
Tags value store

If you are building a large amount of traffic that can carry WEB Service, how is that supposed to be built?

such as: a host build LAMP or lnamp(linux+nginx+apache+mysql+php), in which Nginx is very easy to serve static content, performance is very good, it is easy to host more concurrent links, NGINX has two functions:1, for all static content can be directly feedback;2.send all dynamic content via reverse proxy to AMP(apache+mysql+ PHP is built into a dynamic server where APACHE does not serve static content and only serves dynamic content. As

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/69/wKiom1VjLPmhSCVvAAA4p9Yg33E121.jpg "title=" 1.png " alt= "Wkiom1vjlpmhscvvaaa4p9yg33e121.jpg"/>

because LAMP built on a single host as the user increases, the number of concurrent accesses to lnamp surges, and the server cannot host numerous requests, so it cuts its lnamp on one host into two hosts, and the first host provides Nginx, in the local service to static content, while the reverse proxy for all winter dynamic content to the second server AMP, so thatthe static content of 80% by NGINX processing,20% Dynamic content to AMP processing, so that the system's load-carrying capacity is correspondingly improved. As

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/69/wKiom1VjLTmxBDYOAABKvJZ-RRQ486.jpg "title=" 2.png " alt= "Wkiom1vjltmxbdyoaabkvjz-rrq486.jpg"/>

but as the number of users continues to increase, the front-end NGINX can still handle the request normally, but the backend AMP has insufficient load capacity. This splits again, puts the AP on one host,and MySQL on the other (because the MySQL resource is in high demand and consumes both memory and CPU), so all the dynamic content 80% processing data for the program, only the 20% will use the database, so that MYSQL and AP pressure will be smaller. For example, but MYSQL processing speed <AP processing speed <nginx processing speed , so you need to add a cache to deal with the processing speed mismatch, it is necessary to expand again. As

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/69/wKiom1VjLazDoiTtAAA54NnWn3g921.jpg "title=" 3.png " alt= "Wkiom1vjlazdoittaaa54nnwn3g921.jpg"/>

as the number of user visits continues to increase,Nginxand theApmay be stress-free, butMysqlthe pressure is getting bigger and now it needs to beMysqlexternal Add public cache (key value storage, side-hanging cache, the data in the cache is hotspot data, also can do cluster, but there are more problems, such as to achieve accurate query, need some algorithm (except modulo redundancy method, consistency Hashi) can be achieved, and in the case of frequent updating of data is not very useful), so , whenApIf you need to query the data, ask the public cache first, if the data is found, then return directly, if no data is found, enterMysqlquery. Similarly, whenNginxdynamic content needs to beAprequests, andApmany of the files generated in the program are invariant, so theApThe front end can also add cache (key value store, pass-through cache), so thatNginxrequests are sent directly to the cache, then returned, none from the cache to theApif properly designed, the80%dynamic requests are returned directly by the cache, which reduces theApthe pressure, whileNginxThe performance of the front-end response can also be improved accordingly. As

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/64/wKioL1VjL12QiFUAAABpUzpfdnM523.jpg "title=" 4.png " alt= "Wkiol1vjl12qifuaaabpuzpfdnm523.jpg"/>

not only can the reverse proxy cache be built within the system, but the user and NGINX can also have a reverse proxy cache, when the user requested the first request is a reverse proxy server, such as the 80% service in the reverse proxy cache to get back, then reduce the overall burden of the system, so that the layer added cache, that is, to accelerate the service, but also reduce the system pressure. As

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6D/69/wKiom1VjLe6TUouFAABvLcMfL6Q514.jpg "title=" 5.png " alt= "Wkiom1vjle6tuoufaabvlcmfl6q514.jpg"/>

if the user to the system between the cache is not enough, you can also do CDN, in the engine room across the country to deploy the cache server, such as the content of the request is not in the cache server, and then by the cache server to the upper cache server requests, the hierarchy of cache server requests are not after the host in the room server to initiate requests, and then through the process. This greatly reduces the load on the system.

If not, you can follow the following three points:

1, in the system problems in the link to do cluster bar (for MYSQL master from or slice);

2, wall;

3, change the job.

If the above content is biased, look correct.


Layered construction of Web services

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.