Transfer from http://blog.csdn.net/moshengtan/article/details/8990052
1 Web Load Balancing
1.1-Implementation with commercial hardware
The most frequently used F5 with Citrix NetScaler. For example, 12306 front-end Web seems to be using F5 BIGIP. If the company has enough money, the relative use of open source software to reasoning convenience.
Advantages: Easy maintenance, stable performance
Cons: Too expensive
1.2-Using Open source software
You can choose to use LVS or Nginx for Web application load balancing.
LVS works under the TCP protocol Layer 4, and Nginx works under the TCP protocol layer 7. 4-Layer and 7-layer differences give a practical example: member.app.com,shop.app.com domain name has only one IP, through the LVS point to the background 10.0.0.1-10.0.0.10 the 10 machines. You have to configure the site content of member.app.com and shop.app.com on all 10 machines. These 10 servers all carry front-end requests for member.app.com and shop.app.com, assuming that you find that the member.app.com request is larger than the shop.app.com one day. The shop.app.com request is only limited to the 10.0.0.1-10.0.0.5 5 machines, and member.app.com is pointing to 10.0.0.1-10.0.0.10 10 machines. You must also point the member.app.com and shop.app.com domain names again to different IPs for implementation. The configuration file can be implemented by Nginx. Member.app.com and shop.app.com domains will not be directed to different IP addresses.
Compared to LVS, nginx can achieve more functions. Just relative to stability and performance is better than the performance of LVS.
Advantages: Free, open source. Stable performance.
Cons: High Maintenance configuration costs
1.3-Use the Windows-borne interoperability software
The WINDOWS2003 server is implemented with NLB. Implementation mechanism is similar to LVS, can not do above Nginx seven layer protocol. Using a Windows implementation is broadcasting the request to all IPs on the same network segment. Assuming that the NLB implementation is implemented, it is best to divide the same set of NLB servers under the same VLAN. To prevent broadcasts to other IPs, add traffic to the switch.
Pros: Free (just have windows on your own), easy to configure. You do not have to add a separate server.
Disadvantage: The implementation of data broadcast mode, the need to configure VLAN resolution.
1.4-Summary
The mutual load equalization achieved by the above three methods has its own merits. Assuming a small Windows site server, using the NLB implementation under Windows is a good choice. You do not have to add a separate server. Large or larger sites are recommended to use the hardware (F5 big-IP) or open-source LVS and Nginx to achieve. Individual or more than the nginx to achieve, convenient dynamic Web server to adjust.
2 static Sites
Static sites store static Web content (html,js,css,jpg,png) and users upload files and images in relative terms.
2.1-Static Domain name Division
Relative static sites recommend that Css,jpg,png and user uploads be placed on a different domain name than the primary site. Does not mean a level two domain name, is a domain name. such as the main site with www.website.com, while css,jpg,png and users upload files using file.imageswebsite.com domain name. The main advantage is that cookies that reduce the primary domain name are sent to the file server, which does not require the use of cookies. Can play a role in accelerating user access and reducing server traffic. For example: The user's login information cookie is written to the website.com domain name, each time the browser requests website.com domain name (including two-level domain name) regardless of the URL will be the cookie information sent to the request URL information header. Files that do not require access to user cookies are placed under different domain names and will not be sent with cookies. We are interested in being able to use Firebug for monitoring and viewing.
2.2-Caching of static sites 2.2.1-using CDN
The full name of the CDN is the Content Delivery network, which is the contents distribution networks. The goal is to add a new layer of network architecture to the existing Internet, advertise the content of the site to the "Edge" of the network closest to the user, so that users can get the content they need, solve the congestion on the Internet, and increase the responsiveness of the user to the site. From the technical comprehensive solution because of the network bandwidth is small, the user access to ask large, dot distribution is not equal to the cause of the user visits to the site response slow problem. (that is, the content of a server, the average division to multiple servers, server intelligent identification, allowing users to get away from the user's recent server, the speed of
If the funds agree, you can use a commercial CDN service. You can use CDN acceleration for static sites simply by pointing the domain name to the server specified by the CDN service provider. Domestic Common CDN Network homestay, Blue, deem, etc.
2.2.2-Build Your own CDN
Suppose you have servers in all the rooms in the country can also build their own CDN services.
Using hardware (F5 big-IP), the user is referred to the recent IDC room server based on the IP requested by the user. Then use squid as a reverse proxy on each IDC room server to read the static site from the source server, the cache of the site content and the user upload picture. This allows for accelerated content.
3 Dynamic Sites
Dynamic sites are more interactive with users than static sites. The technology for developing dynamic sites is relatively diverse (asp.net,php,jsp, etc.).
3.1-Domain name Division
Dynamic site domain name recommendations based on the function point, using a two-level domain name to be divided. For example, an e-commerce site, including members, shopping malls, orders, payments, management backstage and so on.
Member Member.website.com
Mall shop.website.com
Order Order.website.com
Payment pay.website.com
Manage Background manager.website.com
In principle, dynamic Domain name only the dynamic program, dynamic site to use the CSS, images should be in the static domain name of the picture server (file.imageswebsite.com). Reduce traffic and requests for programs under dynamic domain names.
Dynamic sites using two-level domain names to divide functionality has the advantage of the sharing of cookies information. All two-level domain names only need to write the cookie information to the website.com domain name, under the other xxx.website.com domain name can read normally. It is now convenient for unified authentication on each dynamic domain name.
3.2-File Upload and display
Because our dynamic site is multiple deployments, when a user uploads a file, we cannot exist on the local server as a single server (other servers cannot read). Instead, you need to make the user files a centralized place to store them.
3.2.1-Stored in the database
All webserver, save the user's upload file in the database. Unify read and write from the database.
The least recommended way. Relative to the database is the most expensive resources, to save user files is the most wasteful. Also, when user data gets bigger, it's the most painful problem for DBAs. Not easy to do cache and file distribution synchronization.
3.2.2-stored in file server
Write
A) Install Ftpserver on the file server. Then each webserver, by simulating ftpclient. Upload the file to the file server via the server's intranet. (C # Analog FTP mode, you can download Discuz NT source Code view, there are implementation methods. )
b) through the shared directory of LAN in Windows, each webserver simulated Windows user access shared folder is written to the file server.
Read
Read the file, assuming it is a non-public file, or read it through the original write file server.
The assumption is an openness to the file, such as the sub-picture. Create a Web site as a data source on the file server, and point the root folder to the folder that the user uploads. Then through the article "static site Cache" method, the user uploads the file site to do CDN distribution and caching. This allows users to upload files for accelerated interview.
3.3-Dynamic Site content updates
Because of the distributed deployment of a dynamic site, updates to one site need to be synchronized to other servers. A special test webserver is recommended for each update to upload the file to the test server. After testing, the updated site files are synced to other webserver by synchronizing the software. You can use rsync for file synchronization, with Linux and Windows versions. Windows Installer Rsync believes that trouble can also be achieved with software such as the King of the day sync.
3.4-Dynamic site caching technology
Memcached
Both Linux and Windows have the appropriate client and server side. Assuming high performance requirements, it is recommended to install a higher server performance under Linux. The client can be called with. net,php.
Developing related caching services
You can also develop your own distributed cache service based on the needs of your business. Caching algorithms often use the LRU algorithm, which is often used in the first order. Introduction to caching service-related algorithms
Http://www.blogjava.net/DL88250/archive/2011/01/21/343327.html
The development of partial caching through remoting is possible under. Net.
Distributed cache you can take a test.
Http://wenku.baidu.com/view/0d0ef4ea81c758f5f61f67d9.html
3.5-Configuration file
Typically, the configuration files for our application are placed under the current program folder. Because our web application is deployed separately, suppose a configuration node changes content. You need to synchronize to another server. In addition, the general program is initializing the read configuration content. Suppose that the configuration changes in the execution of the program only once again the startup program is updated. There is a problem with configuring synchronization.
3.5.1-implemented via synchronous software
Like dynamic site content updates, the configuration files are synchronized using rsync or the Sync software. When the UAT environment configuration changes, the files are synchronized manually or regularly. The application periodically updates the configuration from the configuration file.
3.5.2-Implemented by Configuration service
Develop the Configuration service program, provide the interface for each application to read the configuration method. The Configuration service program and each application implement the configuration content read in real time by TCP.
3.5.3-Through database implementation
Writes configuration content to the database, and each application is implemented by reading the database configuration. Each application initializes the contents of the configuration from the database and updates the content from the database every fixed time after the read is completed to local.
4 Web Performance
4.1-Page compression
Static site compression can be configured by reverse proxy squid. Frequent use of the browser supports the compression of gzip Web format.
Dynamic site, the webserver of each platform has a configuration option that provides page compression. Basically everyone on Google search a search has been conquered.
4.2-Web Client cache
Set the last-modified and ETag of a static Web page file on webserver. Assuming that the file on the server is not updated, no new content is sent to the client.
4.3-Web development content Adjustment
A) merge multiple JS files or CSS files into the same file. To reduce the HTTP request. Each browser has a connection limit for HTTP requests under the same domain name at the same time.
b) Place CSS file styles on the header of the content of the Web page file, and JS file at the bottom of the Web page file. Let the browser load the CSS file first, so that the interface is presented to the user the first time.
c) Web Small icon can be merged into the same large file icon to reduce the HTTP request. The display of individual files is implemented through CSS Sprites.
d) Install YSlow in Firefox to test the performance of the Web page and optimize the content of the Web page based on the test recommendations.
5 Database
When a database is established, there is a pre-allocated space for the database. It is recommended to have a larger initial size, which avoids the space allocated to the database when inserting data. The database's own active allocation of database space affects the performance of database insertions. In addition, the database's own proactive growth is recommended to grow at a detailed size, for example 2G based on your own estimate size. Prevent too fast to reach the database upper limit leads to the system frequently allocates space for the library.
5.1-Database planning
Web sites often use data mysql,mssql,oracle, and of course there are other databases. Basically, these three kinds of databases have their own pros and cons. MySQL free open source, MSSQL and Oracle are commercial software. Oracle is used for large-scale enterprise databases, with more Oracle for general Telecom banks. And MSSQL is relatively small. From a DBA's professional perspective, Oracle performs better than MSSQL and, of course, costs more. From the recent years, MSSQL has been slowly catching up. Databases can also consider NoSQL databases, MongoDB, Redis, and so on. In addition, open source PostgreSQL is said to be good, available to everyone to see (http://bbs.chinaunix.net/thread-1688208-1-1.html)
5.2-Database Partitioning
Divide the database according to the business application. As we above the e-commerce site we can be divided into member,shop two libraries. Member storage is used for member information, shop store stores goods, orders, payment information.
5.3-Table Partitioning
It is suggested to divide the table of big data, and divide the rules according to the number of records, the time of recording and the hash value of records.
If the funds agree, you can consider the storage device. The increase in data performance is enormous.
6 Server Monitoring
The server monitoring described here is only for monitoring the execution state of the webserver. For example, network traffic, CPU, memory, hard disk load. Server monitoring is common through the SNMP protocol and is common under Linux and Windows. For server monitoring I recommend using the cacti software. The server is configured with a dual network card, an intranet, and an external network. Add the SNMP protocol on the internal NIC, and then add the server that needs to be monitored in the cacti. To cacti an extranet IP, you can view the status of the server through the Web interface. Cacti Software Introduction and configuration We can search the Internet, here do not introduce. Cacti is also able to monitor the execution process on the server, assuming that the process stops executing to send alert messages.
7 Web System Logical architecture diagram
Considerations for Web site architecture design