Factors to consider in Web site architecture design

Source: Internet
Author: User
Tags mssql mysql free snmp test web server ftp client rsync

Transfer from http://blog.csdn.net/moshengtan/article/details/8990052
1 Web Load Balancing
1.1-Implementation with commercial hardware

The most commonly used F5 and Citrix NetScaler. For example, 12306 front-end Web seems to be using F5 BIGIP. If the company funds enough, the relative use of open source software to reason convenient.
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 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 member.app.com and shop.app.com website content on all 10 machines. These 10 servers all carry member.app.com and shop.app.com front-end requests, and if one day you find that the member.app.com request is greater than the shop.app.com request. The shop.app.com request is only limited to the 10.0.0.1-10.0.0.5 5 machines, and member.app.com points to 10.0.0.1-10.0.0.10 10 machines. You must re-point the member.app.com and shop.app.com domain names to different IPs for implementation. And through Nginx can be implemented to modify the configuration file. Member.app.com and shop.app.com domains will not be directed to different IP addresses.
Compared to LVS, nginx can achieve more functions. However, compared to the stability and performance of the LVS performance is better.
Pros: Free, open source. Stable performance.
Cons: High Maintenance configuration costs

1.3-Use the Windows-borne interoperability software

WINDOWS2003 servers are implemented from NLB. Implementation mechanism is similar to LVS, can not do above Nginx seven layer protocol. Using a Windows implementation is a broadcast that sends a request to all IPs on the same network segment. If implemented through NLB, it is best to divide the same set of NLB servers under the same VLAN. To prevent broadcast to other IP, increase the traffic of the switch.
Pros: Free (as long as you have windows on your own), easy to configure. Do not add a separate server.
Disadvantage: The data broadcast method is implemented and VLAN resolution needs to be configured.


1.4-Summary

Compared with the above three ways to achieve the mutual load equalization has its own advantages. If a small Windows Web site server, using the NLB implementation under Windows is still a good choice. There is no need to add separate servers. Large or larger Web site recommendations or using hardware (F5 big-IP) or open source under the LVS and Nginx to achieve. Individual or compared to nginx to achieve, convenient dynamic Web server to adjust.

2 Static Websites

Static Web 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 web site is recommended to put css,jpg,png and user upload files on the main site and different domain name. 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 benefit is that cookies that can reduce the primary domain name are sent to a file server that 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, every time the browser requests website.com domain name (including the level two domain name) any URL will send the cookie information to the requested URL information header. Files that do not require access to user cookies are placed under different domain names and no cookies will be sent. We are interested in using Firebug to monitor the view.

2.2-Caching of static websites 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, publish 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 users to the site. The problem of the slow response speed of the user visiting website caused by the small network bandwidth, the large number of users, and the uneven distribution of dot is comprehensively solved technically. (that is, the content of a server, the average division to multiple servers, the server intelligent identification, so that users get to the nearest user server, improve speed

If funds permit, commercial CDN services can be used. You can use CDN acceleration for a static website by simply 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

If you have a server in the national Computer room can also build their own CDN services.
Using hardware (F5 big-IP), the user is referred to the nearest IDC room server based on the IP requested by the user. Then in each IDC computer room server use squid do reverse proxy to read from the source server static website, the content of the site and the user upload image cache. This allows for accelerated content.

3 Dynamic Websites

Dynamic websites are more interactive than static websites. The technology for developing dynamic websites is relatively diverse (asp.net,php,jsp, etc.).

3.1-Domain name Division

Dynamic site domain name recommendations based on the function points, using a two-level domain name to be divided. For example, an e-commerce site, including members, shopping malls, orders, payments, management and other background.
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 Web site to use the CSS, pictures should be in the static domain name of the image server (file.imageswebsite.com). Reduce traffic and requests for programs under dynamic domain names.
Dynamic website use two level domain name to divide the function has a benefit can realize the sharing of the cookie 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. Thus, it is convenient to realize the unified authentication on each dynamic domain name.

3.2-File Upload and display

Since our dynamic Web site is multiple deployments, when users upload files we cannot be 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 Web servers, 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-Store on file server

Write
A) Install the FTP server on the file server. Then each Web server, by simulating the FTP client. The file is uploaded to the file server through the intranet of the server. (C # Analog FTP mode, you can download Discuz NT Source view, there are implementation methods. )
b) Each Web server simulates a Windows user access shared folder to a file server through shared folders on a LAN within Windows.

Read
Read the file, if it is a non-public file, or through the original write file server way read.
If it is an publicity file, such as a picture. A Web site is built on a file server as a data source, and the root directory is referred to the folder that the user uploads. Then through the article "static website cache" method, the user uploads the file site to do CDN distribution and caching. This allows users to upload files for accelerated access.

3.3-Dynamic Site content updates

Because of the distributed deployment of dynamic Web sites, updates to one site need to be synchronized to other servers. A dedicated test Web server is recommended for each update to upload files to the test server. After the test passes, the updated web site files are synced to the other Web servers by synchronizing the software. You can use rsync for file synchronization, with Linux and Windows versions. Windows installation Rsync feels that trouble can also be achieved with the related software such as the King of the day synchronization.

3.4-Dynamic website Caching technology

Memcached
Both Linux and Windows have a corresponding client and server side. If the performance requirements are high, it is recommended to install the server under Linux with higher performance. The client can be called with a. net,php.

Developing related caching services
You can also develop your own distributed cache service according to the needs of your business. Caching algorithms are commonly used in LRU algorithms, often using the sort at the front. Introduction to caching service-related algorithms
Http://www.blogjava.net/DL88250/archive/2011/01/21/343327.html
The development of partial caches can be done through remoting under. Net.

The distributed cache can be consulted
Http://wenku.baidu.com/view/0d0ef4ea81c758f5f61f67d9.html

3.5-Configuration file

Typically, the configuration files for our application are placed in the current program directory. Since our web application is deployed separately, if a configuration node content is modified. You need to sync to another server. In addition, the general program is initializing the read configuration content. If you modify the configuration in the program run, only the restart 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 is modified, 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 to local at regular intervals after the read is completed.

4 Web Performance
4.1-Page compression

Static website compression can be configured by reverse proxy squid. Popular browsers support the compression of gzip web formats.
Dynamic Web site, each platform's Web server has a configuration option that provides page compression. Basically everyone on Google search has been solved.

4.2-Web Client cache

Set the last-modified and ETag of a static Web page file on the Web server. If 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 request for HTTP. 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 to show the user the interface.
c) Web Small icon can be combined 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 according to the test recommendations.

5 Database

When a database is established, there is a pre-allocated space for the database. It is recommended that the initial division be larger, so that the benefit avoids the space allocated to the database when inserting the data. Database automatic allocation of database space affects the performance of database insertions. In addition, the automatic growth of the database is recommended to grow at a specific size, such as 2G based on your own expected 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 site common data mysql,mssql,oracle, of course, there are some 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. Since the last few 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, you can take a look at the free (http://bbs.chinaunix.net/thread-1688208-1-1.html)

5.2-Database Partitioning

Divide the database according to the business application. As we have 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 allow, 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 running state of the Web server. such as 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, an extranet. Increase the SNMP protocol on the Internal network card, and then add the servers that need 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 can also monitor the running process on the server and send alert messages if the process stops running.

7 Web System Logical architecture diagram

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.