Once went to the library to read, met a just graduated, in the library to learn PHP, I chat with him, he asked a question, "How to develop a large web site", this problem does not scare me, I understand some, then and he even said with a gestures, went home I thought carefully and thought, I think it's still written in the paper.
Any website is transformed from a small website into a complex website (later we use a mature website to represent a large site)
To start a website can not be very mature, are with the increase in user volume, business functions continue to expand gradually improve
First: the original site architecture
This time should be the simplest architecture, applications, files, databases, web software are placed on a server, such as (this is my current basic architecture, hmm, is the small site)
Second: application, file, database detach
With the development of the business, a server has not met the performance requirements, so this time the application, files, databases on separate server
Third: You can use caching appropriately to improve website performance
Improve the configuration of hardware at the same time, we can also use software to do performance optimization, here we focus on the database cache, can now use software such as Memcache/redis
IV: Improve application server performance with Clustering
Application is the portal of the site, the volume of business, the volume of requests is very large, a single application server can not afford to talk, usually we use the Load Balancer server to distribute requests (also can be said that the application cluster), I am more familiar with or have been using nginx, such as
The following paragraph is seen from others, I think summed up quite right, I personally or mainly use nginx,haproxy know,
Common load balancing technology hardware has F5, the price is more expensive, the software has LVS, Nginx, HAProxy. LVS is a four-layer load balancer, according to the target address and port selection of internal servers, Nginx and Haproxy is seven-layer load balancing, can choose the internal server according to the message content, so the LVS distribution path is better than Nginx and Haproxy, performance is higher, Nginx and Haproxy are more configurable, such as can be used to do static and dynamic separation (according to the characteristics of the request message, select a static resource server or application server).
V: Database Read and write separation
With the increase in user volume, the database will gradually become a bottleneck, the common means is read and write separation (the specific meaning can be Baidu Google), there are commonly used to split the table (horizontal split table and vertical split table, I prefer to say sub-table and sub-Library), MySQL database has a partition, did not play, Just hear the DBA say it.
Horizontal split table: In order to solve the pressure problem of single sheet. A table is split into multiple tables, such as user tables, according to the UID table (e.g. UID% 10)
Vertical split table: In order to solve the table-to-table IO competition, put the related table into a library, such as the commodity table and the order table into another library, the user table into another library
Sixth: Application Business splitting
With the development of the business, the project is very large, the code is very bloated, this time the business needs division, such as questions and answers, blogs, forums, etc. are divided into independent departments
It needs to be divided into business,
Seventh: Improve website performance with Cdn,squid,varnish etc.
I say cdn,squid and varnish please be interested to check the relevant information
CDN is the content distribution network, why exist? Because for the network company, the general own server will be in a place, such as the Shanghai computer room, such as the Hangzhou computer room, but the site is to the whole country to provide services to the world, so the speed of the site is very important indicators, CDN service providers in many places in the country have a computer room, whenever users visit the site The CDN will return the page content directly from the nearest room.
At present my personal blog has the use of seven KN CDN, talking about family relocation static files to CDN
A detailed introduction to the CDN service I will introduce you in another article, please follow the blog
Summary of the mature large-scale website are constantly optimized, are with the development of the business slowly change
Original address: Interpreting the evolution of large-scale websites
Interpreting the evolution of large Web sites