In half a month 2013 The Spring Festival is coming , Every year, people who work in other places will worry about booking tickets . Especially booking tickets online , Yes 12306 There will be a variety of views on the online booking system provided to , from
Last year's Spring Festival , Launched by the Ministry of Railways 12306 website , Real name online ticket purchase , Every homecoming thought he could buy a train ticket to go home , But the results were disappointing . Last year ,7 day
within ,12306 Website users have accounted for the global Internet users 0.902%, Hits per day up to 10 100 million person times , For a time, the system was unable to support such a large number of visits and collapsed .12306 website
The number of hits belongs to 10 million PV level , If we want to meet the actual requirements , Then we need to be able to deal with the large-scale concurrent access of the website , This problem , A lot of large website stationmaster also may face . To solve the problem of large-scale website
Performance degradation caused by concurrent access , There are many common methods , We can consider and optimize from the following aspects ?

  One , Server configuration optimization

   We need to plan the number of application servers according to the performance of application servers and the size of concurrent visits . There is a usage principle : The performance of a single application server is not necessarily the best , But the quantity must be enough
enough , It is better to have some redundancy to ensure the server failure . especially , During high concurrent access peaks , Appropriately increase the number of servers for some key applications . For example, in some peak query services , Multiple services can be used
implement , To meet the user's millions of hits per hour .

Two , Using load balancing technology

   Load balancing technology is the core technology to solve centralized concurrent access , It is also a more effective method to solve the problem of large-scale concurrent access . The main equipment of load balancing technology is load balancer server . example
as , We deployed the site on two different servers ( The premise is to ensure this 2 Server or multiple servers can run the website program normally ), The load between these servers is achieved by installing specific software
equilibrium . that , A moment , When the site is facing large-scale visits , The user's request will go through the load balancing program , According to the busy and resource situation of different servers , Automatically assigned to servers with optimal processing performance , from
The high concurrency access generated by large-scale users is evenly distributed to each server . This can greatly reduce the single server processing high concurrency request , Ensure the reliability of the whole website system under high load .

  Three , Database structure design

   This part is about the program layer , It's usually done by a software engineer , Yes SQL Statement . The measures we can take include : Index frequently queried database fields , Database table
Partition operation ( It is necessary to partition massive data , For example, for data accessed by year , We can partition by year ), Query statement on Database -SQL( Reduce redundant database operations , carry
High query efficiency ) Optimization, etc .

Four , Optimization of Middleware

   So called Middleware , It's going to sound a bit like deep technology , Actually, it's right next to us , Every stationmaster friend often uses when the website deploys Apache,IIS,Tomcat,
WebLogic It's all middleware . Middleware is mainly located on the client side / On the operating system of the server , Responsible for computer resource management and network communication . Take a simple example , We're deploying JAVA Project's
time , It's usually used Tomcat middleware , that Tomcat It is not optimized by default , In the case of high concurrency , It's very easy to crash . about Tomcat The optimization of is given as follows
proposal ( I feel more important in the actual project development process ):① Thread pool optimization ;② Start memory optimization ;③ Log output optimization ;④HTTP Compression optimization ;⑤ Profile optimization .

   The example above Tomcat middleware ( that is WEB The server ) Just one example , Different websites have different architectures , Then there will be different ways to optimize the corresponding middleware , Like Microsoft
Of IIS There are corresponding configuration parameters , Therefore, the specific optimization method can be based on the needs of the project , Consult the official documentation of middleware for parameter setting , Only in this way can the optimal setting of middleware be realized .

  Five , The use of data cache technology


   Most large websites now use caching technology , The user often uses the data through the cache (Cache) Technology Management , This reduces the pressure on the server to re request , Speed up access to the website . There are many caching technologies , Here I personally based on the actual project experience , It can be divided into 2 species , Data cache and page cache .

  ① The so-called data cache , It means that the data in the database is not transmitted directly , Instead, the data is called to memory , And then read it from memory , This can greatly improve the reading speed . There are many ways to cache data
case , Because of open source , High performance , Recommended use Memcache To set up data caching technology to speed up dynamic web application program , Reduce database load .


  ② Page caching is targeted at public pages to some extent , Static is also a kind of page caching , Generate static pages from the pages frequently visited by users in the corresponding directory of the server , When the user visits again , There is no need to make dynamic requests to the server , And only need to cache the html Direct page reading , In this way, the efficiency of access can be effectively improved .

Technology
©2019-2020 Toolsou All rights reserved,
One is called “ Asking for the train ” A small village Finally got the train SparkSQL Achieve partition overlay write Character recognition technology of vehicle license plate based on Neural Network c++ Memory Pointer out of bounds detection mechanism _CrtMemBlockHeade Change one's mind ! Tesla starts to deliver made in China to European market Model 3Qt study 7—— Modal and modeless dialog boxes JavaScript Medium Call and ApplyJAVA Convert a string to a numeric type k8s Entry to give up --k8s Key concepts Count the number of letters (java Language implementation )