In large websites, the pages that visitors see are basically static pages. Why static pages? There are many benefits for static pages. For example, the access speed is fast, which is more conducive to search engine indexing. Currently, there are two main types of static data:ProgramCapture and save a dynamic page as a static page. The page actually exists in the server's hard disk. Web Server URL rewrite The principle is through Web The internal module of the server URL The request is converted to an internal file address. In one sentence, the static address of the external request is converted. Is the actual dynamic page address, but the static page does not actually exist. Both methods are implemented. URL Static effects, but they also have their own characteristics.
This method converts a dynamic page to an existing static page. Because of the existence of a static page, the dynamic parsing process is reduced, which improves the access speed and stability of the page, this makes the optimization effect very obvious. Therefore, this method is widely used. However, its limitations also exist. For large websites, this method will bring about problems that cannot be ignored.
1. because a large number of files are generated, storage needs to consider the number of files and folders and disk space;
2. The complexity and workload of page maintenance, as well as the timeliness of page maintenance, require a complete set of site update systems.
and URL rewrite the method features exactly the same, because the address is resolved inside the server, the content is updated in real time, and there are no file management and hardware problems, making maintenance easier. At the server level URL rewrite rewriting does not affect the page execution speed. However, URL rewrite the threshold is relatively high, most of the domestic virtual hosts are not supported, and the virtual hosts are directory-level URL rewrite, traverse directory books URL the forwarding rules greatly reduce the page execution speed.
Besides capturing dynamic pages andURL rewriteIn addition, here we will look at another method. The core idea of this method is: divide the page into sub-data blocks, and each data block may beINCFile, or multiple data blocks may be contained in oneINCFile. The specific data block division is processed according to the service structure of the page. For example, a public data block such as the head and end of a website can be an independent file. The following aspects need to be considered for this method:
1How to generate pages and data blocks
2Page Update mechanism;
3, The maintenance of a large number of page files;
4Page data block timeliness.
In this way, you can usually add a service program in the background to generate a page for a channel or column. Although this method is feasible, the logic structure is clear Based on the channels.
[Single service mode]
This will cause some problems. For example, after a channel is modified, the corresponding service programs must be repeated. If there are many channels, there will be a lot of corresponding service programs, resulting in a large workload for program maintenance. Front-end developers should not only create pages, but also consider the background service program structure, which increases unnecessary development difficulty and reduces development efficiency.
[Multi-service mode]
In the multi-service mode, multiple services compete for command data. The status of the action command must be synchronized between multiple services. If the service is upgraded, update the service one by one. If an error occurs, troubleshoot the problem one by one ......
Is there a way to independently abstract the page generation function into a platform and provide a program interface. Front-end developers only need to follow this interface to develop business components. Now, the front-end developers only need to deploy the business components to the specified place. The rest is handed over to this platform, which simplifies system release and maintenance, reduces the workload of front-end developers, and improves their development efficiency.
[Centralized platform processing mode]
An action instruction is a page update action. When the page data changes, an action is triggered from somewhere according to the business rules. There are roughly three sources: foreground page triggering, background content management system triggering, and background automatic and timed triggering.
Interface Design of the static data generation system and business components. Call business components through reflection. The interface parameters can be expanded based on the instruction structure. For example, add some Error Descriptions and database link objects.
Data distribution is an independent data transmission system, which is responsible for transmitting the generated page data to the specifiedWebServer.
In order to make the system horizontally expand as the website traffic increases, the speed of instruction processing is accelerated. Therefore, you need to deploy the system on multiple servers, so that all subsystems must communicate and coordinate in a unified manner. Available MQ Messages serve as means of communication between subsystems. Subsystem deployment mode changed Master-slave . Master The system on the host is responsible for reading commands, and then sends the commands MQ . Various Slave The host system is responsible for receiving MQ Message command, call business components, and update the status of a command. In this way, the average pressure on the processing business logic is allocated to each Slave Host.
For a large website, there will be a lot of page data generated, and managing these page files is a problem. For example, some pages have been deleted, and the generated page data will still exist inWebServer. In this case, you need to use the background system to record the deployment location of these page files for future unified management. At the same time, there may be a large number of business components, especially in the case of multiple versions, you also need to record the configuration of business components to the database for unified management.