Analysis of QBlog technical principles in the autumn color Garden: Performance Optimization article: continuous cache solution with total invalid cache (14th)

Source: Internet
Author: User
Tags mdb database vps

Review:

1. Analysis of QBlog technology principles in the autumn Garden: Opening part: Overall understanding (1) -- introduces the role of the overall folder and file

2: Analysis of QBlog technical principles of the autumn color Garden: Understanding the whole site processing process (2)-introducing the business processing process of the autumn color Garden

3: Analysis of QBlog technical principles in the autumn color Park: UrlRewrite's principle of URL without a suffix (3) -- introduces how to implement URL without a suffix

4: Analysis of QBlog technical principles in the autumn Garden: URL redirection System of UrlRewrite (4) -- introduce how to locate the processing program in the URL

5. Technical Principles of QBlog in the autumn color Park: Module-based page base class design (5)-Introduction to creating base classes and custom lifecycles

6: Analysis of QBlog technology principles in the autumn Garden: Module Page Base-Lifecycle Process (6)-Introduction to internal services of the basic Lifecycle

7. Technical Principles of QBlog in the autumn Garden: Module-based lifecycle-page loading (7)-Introduction to html Loading Principles

8. Technical Principles of QBlog in the autumn Garden: webpage processing-content filling (8)-How to fill html content

9: Analysis of QBlog technology principles in the autumn Garden: unique multi-language translation mechanism (9)-Introduction to the principles of html multi-language translation

10: Analysis of Technical Principles of QBlog in the autumn Garden: demo of page content filling and multi-language translation process (10) -- Summary DEMO code

11: Analysis of QBlog technical principles in the autumn Garden: page Post Submission mechanism (11) -- Introduction if Post submits data

12: Analysis of QBlog technology principles in the autumn color Garden: Performance Optimization: byte and cache and concurrency (12)-Performance Optimization: byte, concurrency and Cache

13: Analysis of QBlog technology principles in the autumn Garden: Performance Optimization article: Global SQL statement optimization (13)-Introduce Global SQL and perform targeted Optimization

Appendix:

1: Analysis of QBlog technical principles of the autumn color Garden: technical implementation of one-click blog Installation Tool [Download source code] -- Principle of the open source autumn color garden Installation Tool

2: how to install and deploy the CYQBlog site of the autumn Garden

3: how to install and deploy the CYQBlog site of the autumn Garden in Windows 7

 

PS: QBlog: Http://www.cyqdata.com/download/article-detail-427

 

The last two short reviews:

In the last two sections, I introduced the performance optimization of QBlog in the autumn Garden:

For example, reduce the byte output size, write concurrency control, and Cache control.

In particular, cache processing ensures global control, memory resources optimization, and reasonable optimization.

At the same time, CYQ. Data has some advantages in performance tuning.

Including: CYQ. Data another optimization solution: by printing the Page SQL, capture the SQL statements that have been executed for a long time for targeted optimization.

 

This section introduces:

This section describes QBlog Another method for website optimization: the post-completion scheme after cache failure, semi-Static html, and continuous cache construction.

 

Miscellaneous:

Autumn GardenQBlog Access has been used all the time, including now, the size of the mdb database is MB:

I tried to change the database. For example, I mentioned that the QBlog of the autumn garden was promoted from Access to MSSQL, but I still didn't change it at the end. The reasons mentioned in this article will not be repeated.

Recently I bought a VPS and moved the autumn garden to the gambling City "Las Vegas ".

At the same time, we also conducted a variety of database tests and successively ran the databases supported by the CYQ. Data framework, including Access, mssql2000, 2005, oracle, mysql, and sqlite.

With the help of the CYQ. Data framework, the autumn color garden implements multi-database parsing for some different database differential functions and methods. without modifying the Code, only the database link is switched, so that you can easily run a variety of databases. This will be introduced later.

Although all kinds of databases can run, but there is still no change to the database, still Access:

For the persistence of the Access 0.1 million article, but also to maximize the optimization program.

In fact, the most important reason is that the VPS memory is MB, which cannot handle big data.

 

Honestly, Access is not fast:

When Access reaches tens of thousands of data in a single table, it is difficult to query a single table quickly.

Autumn GardenQBlog The basic speed of the home page is about 3 seconds, and the page is slow for about 5 seconds.

 

Therefore, the acceleration has to rely on program optimization:

To speed up,Autumn GardenQBlog Adhere to the function of program structure and control, soAutumn GardenQBlogStep 1With the cache mechanism.

But the cache is always invalid. How can I keep quick access after the cache becomes invalid?

 

There are two solutions behind cache invalidation:

 

Solution 1:Post-Cache generation: takes over the cache that is about to expire, constructs a continuous cache, and updates data in a timely manner.Guaranteed.

 

Note:

This solution has been briefly considered and has not been implemented, so it has not been thoroughly studied and implemented.

It should be feasible to guess the implementation. It only requires some technical means.

 

Disadvantages:

When the memory of the IIS application pool is recycled, the overall cache becomes invalid. After the second cache is completed, the cache naturally becomes invalid. Therefore, there will be no blank cache period.

Therefore, another solution, solution 2, was considered later.

 

Solution 2:Generate static pages: temporarily replace the invalid cache and then generate a new cache.

 

Note:

Static pages are temporarily buffered, so that high-speed access can be maintained continuously.

At the same time, you can also avoid the blank period of memory recovery, which is currently used by the autumn garden.

 

Disadvantages:

It is difficult to control the generation of new pages, and the real-time performance is not strong, because the key to data update is static pages.

So I thought a lot of tricks later to skip loading static pages.

 

Static technical means and difficulties of the second solution:

 

1: how to generate static pages? Batch production? Background Program? No...

2: How are static pages displayed? Xxx.html? No...

3: How to Ensure page updates? Scheduled Update? No...

4: Are you willing to make cache supplements ?.... Not easy to say, not good, not good ......

 

Analysis of specific static technical solutions:

 

I. How to generate static pages

 

1: The background program. Click the next button to generate them in batches?

In the past, this was the case when I was doing E-Commerce. I clicked the mouse to generate static pages of products in batches.

Because the basic information of the product is not changed much, and there are only a few editors, it is enough to generate an html when you re-edit the product.

However, this method is not suitable for the autumn garden.

 

2: The scheme of the autumn Garden: the first interview, generate HTML

Currently, this method is used in the autumn garden. Because HTML is used as an Xml loading method, it is quite simple to generate static pages.

Method: Save the Xml InnerXml to the specified path before the page ends.

Simplified problem: how to construct a specified save path.

 

Ii. Presentation of static pages

 

Imagine when accessing:Http://www.cyqdata.com/qblog/article-detail-37431When,

Who took over first? YesURLRewrite, which first parses the URL and then decides the jump path.

 

There are two routes for redirect:

1: Add a logic to determine whether html has been generated and jump to the static html for access based on the conditions.

However, this method is not used in the autumn Garden, but it can also be tried.

2: Use HTML as a cache, read and load it directly, and then continue the subsequent page lifecycle process.

The basic logic is as follows:

If (try to read cache) {return Document from cache}

Else if (try to read html) {load html and return the Document, handle the thread probability, request to update data, and generate a new cache}

Else {Original loading method, still reading the database and generating HTML pages at the same time}

 

PS: Only if and else are available in the autumn garden. Here, else if is easily extended.

 

3. Ensure page updates

 

1: The original loading method. In the last else event above, HTML is generated.

 

2: The above else if event contains probabilistic Event requests. For probabilistic events, the current page is still requested.

 

However, you need to add an identifier so that it can directly locate the final else event to generate a new update page.

 

PS:

For example, if the homepage is cached for 3 minutes and becomes invalid, html will be read from the else if event and an probabilistic event will be generated,

If a new HTML is generated during the first time, and the old data cached for three minutes is generated again, the data is updated every 6 minutes.

If you leave the game for the first time, you will have a lucky draw in three minutes and a lucky draw in three minutes. After you get in the middle, you will see new data in three minutes.

 

Iv. Balance static and cache Functions

 

One pageBasic100 K. If the page is cached, a lot of memory is required.

How many articles can vps m cache? There are N other expenses of the system, which can be saved.

Therefore, the cache expiration and cache time need to be well controlled. how to properly control the cache is also read the previous article: Analysis of QBlog technical principles of the autumn Garden: Performance Optimization: bytes and cache and concurrency (12)

Therefore, you cannot use the cache in a large area. Therefore, you need to balance the usage and a reasonable usage policy.

 

I just upgraded it today. The basic strategy of the current autumn garden is:

1: Home Page: Enable cache + HTML

2: User homepage: enable caching and disable HTML

3: User articles: Disable caching and enable HTML

4. User images: Disable caching and HTML. Few users can use it.

5. Article category: enable caching and disable HTML

 

Conclusion:

 

This section introducesQBlogIn practice, we will continue to introduce the optimization policy in the next section. Stay tuned.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.