The technology and tools involved: Java,springmvc,ibatis,freemarker,mysql,mongdb,memcached,ehcache,maven.
A website can not be said to be the first to design a perfect structure to consider all situations, a mature architecture is the change in demand, traffic increases to change.
Basic architecture:
Web server: Ngnix+apache doing load balancing
Technical framework: Freemarker+springmvc+ibatis (Myibatis) +memcache+mysql
Such a structure of the general site daily UV in the case of Guiwan tens of thousands of, the deployment of a few web machines can basically be satisfied.
First, with the increase in traffic, the home page thought to optimize is the database
1, the sub-Library can be divided according to the division of business modules to reduce the single-Library pressure.
2, sub-table on the individual data volume is very large table, the table, reduce the amount of single-table data, improve query speed.
3, after the library, for the core database, you can do master/slave library processing, the query and update separation, improve the insertion speed.
4, carding business, such as dynamic, such as the amount of writing is very large, after writing does not update such characteristics of the data, can be used mongdb, to achieve higher performance and more simple business processing.
Database to achieve this level, basically almost, the new business comes in, the database can be calmly to expand horizontally.
Second, with the complexity of the business, the database and sub-table, there may be some business process is very long, resulting in the application needs to go to N Library query or update n tables, so that the client's response is very slow, this time need to come out asynchronously.
Recommendation: JMS, using ACTIVEMQ, these spring are very good implementations.
Third, the cache server, the site has some basic information, such as: Site configuration information, login user information, and so on, this kind of core data, almost every request to read, but these data is not how to change, every time also to go to memcache cache server to read, communication between the server is also time, You can consider a local cache.
Recommendation: Ehcach. It is a pure Java in-process cache framework, with fast, lean and other characteristics.
Four, static. Site home, there are two level domain name home page, such as the nature of the pages, the number of visits are relatively large, static off. The scheduled task can be generated once a few minutes.
Recommendation: Quartz. Open-source job scheduling framework. (In fact, this should be integrated in the beginning, because your site will certainly have a similar timing task needs, quartz is the choice of benevolence).
Five, static file optimization.
1, this is the HTML and JS and static pictures, and so on, these optimization schemes are more, JS component, on-demand loading, CSS Sprite and so on, the front-end optimization and profound, here do not say, there are many programs on the Internet, which is a long-term optimization and task.
2, static file storage, Distributed file storage, open source solutions are also many, mogilefs, HDFS
Vi. business decoupling. As the system becomes more and more complex, it is like a huge machine, all the functions are developed on top, the novice, the veteran, regardless of who, in addition to the individual senior programmers and architects, other people may not be able to understand the entire system, it is easy to create bugs, and release becomes a nightmare, as long as there is a personal function problem, The whole system can not be released, everyone has to stop and so on, resulting in a lot of waste of resources, overtime serious. This stage, the system must be split, the system according to the business division, such as user module, blog module, picture module and so on. Each module communicates through an external interface, and each module can be independently deployed independently.
Java Web site architecture design