It has been in contact with DNN for several years, and it has been used for projects for several years. The biggest advantage of using DNN for website creation is that it is fast, convenient to adjust the page layout style, and convenient to Expand functions. However, it also has a fatal weakness: slow access speed.
Based on practical experience of the project, I found that the bottleneck affecting access speed is not on the web server but on the database server. In the case of high concurrency traffic, the database server is under great pressure and the CPU usage is above 80%. A large number of requests are blocked. A request usually takes 1 to 2 seconds to be executed. Once we know the bottleneck problem, we can start to modify it from the following aspects.
1. Optimize the index of the table structure with a data volume of 0.2 million rows to accelerate the query speed of a single select statement.
2. Optimize the writing of SQL statements.
3. Table sharding is necessary for tables with large data volumes.
After the above adjustments, the execution of the SQL statement will be much faster. However, SQL requests are not reduced. To browse a dnn page, you often need to execute many SQL statements. There are modules and frameworks. To reduce the number of SQL requests in this aspect, we need to start with dnn cache.
1. First, set the cache in "host Management> host Settings ".
You can use the default settings to solve the framework-level SQL Request volume, mainly tabinfo.
2. Set a proper cache time in Module Settings to reduce SQL requests at the module level.
This cache time can be set for modules that do not change frequently. The principle is to cache the html generated by this module into a file or memory.
In this way, when the page is loaded, the system will directly display the html in the cache and will not call specific modules, so that all the SQL requests in these modules will not be executed.
After the above optimization, the access pressure on many database servers can be reduced.
Next we will start with data transmission for further acceleration.
First, we should try to reduce the amount of html code when writing a module. Disable unnecessary VIEWSTATE.
Secondly, DNN also provides us with a Gzip compression function. I can enable it in "host Management> host Settings.
In addition, DNN has several functions. If you do not need it, you can turn it off, which will also help improve performance.
1. log function. In DNN, the EventLog table has a large amount of data growth. You can turn it off if you don't need it.
Under "Admin> Event Viewer", edit log settings.
The above are the error types. This reduces the access to many databases.
In addition, you can set the Daily Record method in web. config, for example:
Use XMLLoggingProvider to record logs. It stores log information in xml files, which can also reduce database access.
2. The indexing function in Schedule scheduling. We all know that DNN search does not support Chinese indexes very well. So since his index does not work, it is better to disable it.
In "Host> Schedule ",
We recommend that you use the function of extracting Chinese Word Segmentation in DNN to compile a small windows program and run it in the schedule of windows. In this way, the stability does not reflect the pressure on the web server.
In general, since DNN is also a web program, the optimization methods and principles applicable to other web programs also apply to it. If you have any good methods, I hope you can share them with me.