In the first section we discuss the simplification, if it is simplified, or cannot be simplified, then we must consider decomposition it, then how to divide it? In general, it can be divided horizontally and vertically, or from software and hardware, which is related to the design of our architecture.
My view of horizontal decomposition:
① the so-called horizontal decomposition, is the separation of the various parts there is no obvious hierarchical relationship between each other, the independence is strong, of course, complete independence is unrealistic.
② The 1th idea is according to the function to divide, for example, the website is divided into BBS to exchange problems, blog to display blog information, news to show the press and so on, then you can consider according to the two-level domain name to do the corresponding deployment, such as BBS put on a server, blog put on a server.
③ The 2nd idea is according to the file to divide, we know that the picture is quite resource-intensive, and it is static resources, occupy more IO, and dynamic Parsing Web file is mainly occupied CPU, then you can let Apache to parse Web files, let lighttpd or other server to do picture server , or we can separate out a log server.
④ 3rd is the division of services, we do not necessarily all things to do their own, you can consider to call other sites of external services, such as our use of jquery, Bootsrap and other libraries, you can use Baidu, Sina and other CDN to simplify the call, share server traffic, Of course, because many Web sites provide external services, this is the knowledge pool of friends to see the depth.
⑤ 4th is the division of the module, if a module is more special, you can separate it, separate processing, such as file upload and download, file upload is often a hacker attack is very interested in a link, we also need to upload the resources of strict control, such as the download need to do a good anti-theft chain, Need to prevent user multithreading unlimited download and so on, these modules we can be put forward separately, to carry out strict control, to prevent them from dragging down our performance.
My view of vertical decomposition:
① first is the Web front-end, we put those can be static static page, if the conditions allow, use pure static to generate real HTML page, efficiency will be much faster, such as the homepage of the site, if not real-time updates, then you can consider the use of static way to do. As for pseudo-static, because it is the big website and the meaning of the small site is similar, not introduced.
② then is the back-end model of the separation, if the original is not using MVC can consider using MVC, if MVC is not enough to consider HMVC to add a layer to enhance its extensibility, if the three-tier architecture is not enough to solve the problem of the four-tier framework, of course, for a well-written site, Often faced with emphasis on construction, but also a very headache topic.
The ③ is then cached, and each layer can use the cache. For example, the server can use Web-based reverse proxy servers such as Nginx,squid,varnish and so on, in the Web front-end can consider the use of pages, images, CSS, JS and other caches, PHP can also use the cache, such as APC, Eaccelarator and so on, Of course for and server calls, you can consider memcache and so on.
Sinsing on the second decomposition of the structure of large-scale website