Thoughts on the evolution of large-scale website technology (11)--Static and dynamic separation of website (3)

Source: Internet
Author: User
Tags jboss nginx server

In the previous article, I said that the key point of the static site is dynamic separation, dynamic and static separation is to make the dynamics of the Web site in accordance with certain rules of the constant resources and constant change of resources, static and dynamic resources to do the split, we can according to the characteristics of static resources to do the cache operation, This is the site of static processing of the core idea. Thus, the site of static processing is the core of dynamic and static separation and caching two major aspects, I briefly described the basic knowledge of static and dynamic integration, this chapter will tell the two core of one of the dynamic and static separation strategy, only the static and dynamic separation strategy is done, the cache can play its due effect.

Below we are going to discuss the strategy of static and dynamic separation, what is the content of a page and what is static, how can we distinguish it? The problem of learning is very large, our standards are different, the last split out of the dynamic resources will be very different. At the beginning of this series, I mentioned what kind of page is static page, what kind of page is a dynamic page, I am defined by a URL angle, each individual page will have a URL, this URL is like this page number, Every time we visit this URL if the response page is the same, then we think that the page is a static page, if we visit a URL, we visit different times, the last page is not the same then this page is a dynamic page, dynamic page is we have to carry out the carrier of static and passive separation, We can see that my definition is actually related to the time, that is, the access time is different, the results will be inconsistent, so we can be based on the Time dimension analysis page those content is static, those are dynamic, but this division in the actual situation will become very complex, I will talk about this complexity.

Scenario One: If we are a merchant, we check the transaction data of our shop, generally this transaction data we will be placed in the lower right part of the page, this part we naturally regard it as dynamic resources, even if our shop volume is very small, we do not dare to this part as a static resource processing.

Scenario Two: Our website in order to give users a friendly experience, will be in the site after the user login to display a welcome language, such as: Good Morning, summer forest, welcome to use our website! , in the afternoon, this welcome language may become good afternoon, summer forest, welcome to use our website! , should we consider this piece of content as static content or dynamic content? This needs to be thought out.

Scene Three: There will be a lot of pictures on the site page, some pictures are really long time will not change, such as the site's icon, but some pictures are different, for example, there are one weeks we want to do a marketing campaign for a merchant, then the marketing image this update will have one weeks validity period, complex point, We may dedicate a section of the page to the content area of the merchant's campaign during the marketing campaign, which uses an HTML fragment, but when the campaign is over, the marketing picture may change, and the marketing content area may be removed, So what do we do with static content or dynamic content?

From the above scene we can know, this static separation is to pay attention to strategy, if the strategy design is not good, maybe we put the site static processing, the effect did not meet our expectations. In fact, I think the static and dynamic separation in addition to the time dimension, there should also be a dimension, that is, the split resources need service-side application to cooperate, such as transaction query such as dynamic content, we actually need the service-side program according to certain business logic processing requests from the storage layer to obtain data, So this dynamic resources can not do static processing, there are some resources such as scene three pictures and marketing HTML fragments, these resources written in the effective time will not change, then this piece of content although the timeliness may be different, but it is in this time to do static processing, There is a situation is two, the scene although the use of data need to service the end of the calculation, but the results of the calculation in a certain time range is constant, that is, the result can be cached, then this block of resources can be used as a static resource for processing, why say split strategy to consider the server application factors? Because these scenarios are determined by the server application input form, in the effective time of the server application does not need to participate in, or after one time to save the results, then we can treat these resources as static resources.

In addition, the service-side application and the results of the close degree is to be considered as a factor. In web development, in addition to the browser processing, other technologies can be used as a server to understand, if our site to use a CDN, to use the static Web server such as Apache, as well as the service side of the Web container such as JBoss, then on the requested path of travel, The sooner we deal with that, the more efficient the site responds, so when the request returns in the CDN, it's definitely more efficient than the Apache return, and in Apache it's definitely more efficient than the JBoss return, and the Web container on the server itself is consuming some of the system resources because the server program is running. So it is more efficient in processing requests than CDN and Apache, so when we split up the static resources according to the dynamic separation strategy, this resource can not be processed on the server side of the Web container without being placed on the bottom server.

As mentioned above, we look back at the static Web server SSI technology, which is used similar to our use of include on the service side, but the use of include in SSI will be more efficient than on the service side, because the server will be in the integration of static and dynamic resources are also doped with a lot of service-side program processing , so the efficiency of dynamic and static resources will be greatly compromised. Let's look at the usage of SSI's include as follows:

?

<!--#include file= "info.htm"-

??

This is written using the page's comment label, and when the static Web container processes the request, it scans the SSI tag inside, then handles the label's contents, and if the resource is found then the Web container inserts the resource into the page, and if the web does not process the SSI tag, then the result is the browser. This is also a comment, will not affect the display of the page, and SSI tag processing resources are very rich, whether the resource is static, or dynamic, as long as the acquisition time is a complete resource can be added to the page, so like the previous scene two this dynamic content can be normal processing. So scenario two, scenario three, can be solved using SSI. SSI's role, of course, is not only to do the include operation, its label can also do some logical operation, tell how to use SSI is not the focus of this article, interested friends can go to study.

However, SSI also has its own limitations, its first limitation is that SSI parsing is a static web container to complete, so it consumes the performance of the Web container, if SSI has a certain logic, then this performance will be more expensive to use, In fact, I think the more important thing is that if the static Web container transition uses SSI, then it will turn itself into a server-side web container, in addition to affecting the efficiency of request processing, it will also reduce its own concurrency processing power, so we hope that the resource consolidation strategy to the external service processing effect is better, As some large internet companies use ESI technology, ESI technology is closely related to caching, which I put into the next discussion.

In the end, I want to talk about the CDN problem, I said the static Web container to integrate the benefits of dynamic resources, so I say that if the CDN can do static and dynamic integration, then can be done near the processing, so the effect will be higher, today I do some textual research on this practice, I feel that the statement is a bit inappropriate, At least my current company does not use such technology, CDN technology should be composed of three steps, the first is to resolve DNS, to find the nearest CDN server, the CDN to do a load balancer, according to load balancing policy to land the request to the most appropriate server, If the CDN server has the static resources required by the user, then this resource will be returned directly to the browser, if no CDN server will request the remote server, pull the resources and then return the resources to the browser, so that the pull of resources are also cached on the CDN server, The next visit does not need to request the remote server, the CDN storage resources in the way of using the cache, the vector is similar to the Apache,nginx server, which we generally call the HTTP accelerator, the reason for the HTTP accelerator is to be different from the traditional static Web server, Traditional static resource servers generally read files from persistent devices, while HTTP accelerators are read from memory, but the specific storage calculation model is optimized for the hardware features to make the resource reads more efficient and the common HTTP Accelerator has varnish,squid. Ngnix plus the cache module can also be used as an HTTP accelerator, regardless of the use of any technology CDN server basically is to do a near cache operation, which means that the CDN can complete SSI operation is debatable, so the previous version of the argument is still a bit problematic.

Well, write it here today and wish you all a happy life.

Thoughts on the evolution of large-scale website technology (11)--Static and dynamic separation of website (3)

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.