当前位置:网站首页>Website architecture optimization performance concept

Website architecture optimization performance concept

2021-01-23 16:23:34 Programmer a mu

First site architecture
At first, the business volume was small , Small number of visitors , Architecture at this time , Applications 、 database 、 Files are all deployed on one server , Some even rent only host space

1. application 、 data 、 File separation
Put the application 、 database 、 Files are deployed on separate servers , And configure different hardware according to the purpose of the server , Best performance .

2. Using cache to improve website performance
Most site visits follow 28 principle , namely 80% Access requests for , End up in 20% Data on , So we can cache the hot data , Reduce the access path of hot data , Improve user experience . The common way to implement cache is local cache 、 Distributed cache . Of course, CDN、 Reverse proxy .
2.1 Local cache
Local cache , As the name implies, cache the data on the application server , Can exist in memory , Files can also exist , Components . Local caching is characterized by high speed , However, due to the limited local space, the amount of cache data is limited .

2.2 Distributed cache
The characteristics of distributed cache are , Massive data can be cached , And it's very easy to expand , Often used in portal websites , The speed is not as fast as the local cache , The common distributed cache is Memcached、Redis.


2.3 Reverse proxy
Deployed in the computer room of the website , Access the reverse proxy server first when the user request arrives , The reverse proxy returns the cached data to the user , If there is no cached data, it will continue to access the application server to get , This reduces the cost of getting data .

2.4 CDN
Suppose our servers are all deployed in the computer room in Hangzhou , For Zhejiang users, access is fast , But for users in Beijing, access is slow , This is because Zhejiang and Beijing belong to different developed areas of China Telecom and China Unicom , Beijing users need to go through a long path through the Internet router to access the servers in Hangzhou , The same goes for the return path , So the data transmission time is relatively long . In this case , Often used CDN solve ,CDN Cache data content to operator's computer room , Users access data from the nearest operator first , This greatly reduces the path of network access .

3. Using clusters + Load balancing improves application server performance
Application server as portal of website , Will take on a lot of requests , We often share the number of requests through the application server cluster .
Deploy load balancing server in front of application server to schedule user requests , Distribute requests to multiple application server nodes according to the distribution policy .

The commonly used hardware of load balancing technology includes F5, The price is more expensive. Generally 15W above .
Software is available. LVS、Nginx、HAProxy.LVS It's four floors ( Transport layer ) Load balancing , Select internal server based on destination address and port ,Nginx and HAProxy It's seven stories ( application layer ) Load balancing , Internal server can be selected according to message content , therefore LVS Better distribution path Nginx and HAProxy, Better performance , and Nginx and HAProxy More configurable , If it can be used for dynamic and static separation ( According to the characteristics of the request message , Select static resource server or application server ).


4. Database optimization
4.1 Read write separation and sub database sub table
As the number of users increases , Database becomes the biggest bottleneck , The common means to improve the performance of database is to separate reading and writing, and to divide database into tables , As the name implies, the separation of read and write is to divide the database into read database and write database , Realize data synchronization through the main and standby functions . The sub database and sub table can be divided into horizontal segmentation and vertical segmentation , Horizontal segmentation is to split a large database table , For example, user table . Vertical segmentation is based on different businesses , Such as user business 、 Commodity business related tables are placed in different databases .

4.2 Use NoSql Databases and search engines
For massive data query and Analysis , We use nosql Database and search engine can achieve better performance . Not all data should be placed in relational data . frequently-used NOSQL Yes mongodb、hbase、redis, Search engines have lucene、solr、elasticsearch.

5. Business splitting of application server
As the business expands , The application has become very bloated , At this point, we need to split the application into business segments , For example, baidu is divided into news 、 Webpage 、 Pictures and other businesses . Each business application is responsible for relatively independent business operation . Services communicate with each other through messages or share databases .


6. Using distributed systems
6.1 distributed file system
Users increase day by day , More and more business , More and more documents are produced , Single file server can no longer meet the requirements , Then we need the support of distributed file system . Common distributed file systems are GFS、HDFS、TFS.

GFS(Google File System) It can provide a large number of users with high performance services
• Suitable for deployment on cheap common hardware
• Provides fault tolerance
HDFS(Hadoop Distributed File System) It can provide high throughput data access , Very suitable for large-scale data set applications
• Running on general hardware (commodityhardware)
• Highly fault-tolerant
• Suitable for deployment on cheap machines
TFS(Taobao Flies System) Mainly for massive unstructured data , Provides highly reliable and concurrent storage access
• Highly scalable 、 High availability 、 High performance
• For Internet services
• Suitable for mass small file storage
6.2 Distributed services
Each business application will use some basic business services , For example, user services 、 Order service 、 Payment services 、 Security service , These services are the basic elements to support various business applications . We extract these services and build distributed services using the partial service framework .


Summary
The complete system architecture is as follows :


notes : The architecture of large-scale websites is constantly improved according to business needs , Specific design and consideration will be made according to different business characteristics , This article is just about some optimization techniques and means that a regular large-scale website will involve .
I hope the above will help you , quite a lot PHPer There are always some problems and bottlenecks in the advanced stage , There is no sense of direction in the business code , I don't know where to start to improve , I've compiled some information about it , Including but not limited to : Distributed architecture 、 Highly scalable 、 High performance 、 High concurrency 、 Server performance tuning 、TP6,laravel,YII2,Redis,Swoole、Swoft、Kafka、Mysql Optimize 、shell Script 、Docker、 Microservices 、Nginx If you need advanced advanced dry goods, you can share them for free , Need to click

Down and out programmer :【 The year-end benefits are known 】10 Architects share PHP Advanced architecture information , We can all 30Kzhuanlan.zhihu.com

I hope the above will help you , quite a lot PHPer There are always some problems and bottlenecks in the advanced stage , There is no sense of direction in the business code , I don't know where to start to improve , I've compiled some information about it , Including but not limited to : Distributed architecture 、 Highly scalable 、 High performance 、 High concurrency 、 Server performance tuning 、TP6,laravel,YII2,Redis,Swoole、Swoft、Kafka、Mysql Optimize 、shell Script 、Docker、 Microservices 、Nginx If you need advanced advanced dry goods, you can share them for free , You can join if you need My official group Click here to .

版权声明
本文为[Programmer a mu]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/01/20210123162222090K.html