How to speed up Website access

Source: Internet
Author: User
Tags web hosting
How to speed up Website access

Many of my friends use web hosting as websites to store webpage files in virtual spaces. However, when there are many pages, the website can be opened very slowly. If this happens, it is better to optimize the webpage code to achieve satisfactory speed than to seek a better space. I have summarized some practical methods. When making a homepage, the following methods can greatly improve the speed of your webpage.

I. Remember to help the page to lose weight
We browse the Web page to download the web page content from the VM to the local hard disk, and then explain it in a browser. The speed of downloading a Web page accounts for a large proportion of the display speed. Therefore, the smaller the space occupied by the web page itself, the faster the browsing speed. This requires that you follow the principle of simplicity when creating web pages, such as: Do not use too much flash animation, images and other resources. A clean and concise page will give you a clear idea.

Ii. Try to use static html pages if necessary
As we all know, ASP, PHP, JSP and other programs realize dynamic interaction of web page information, which is indeed very convenient to run, because their data interaction is good, you can easily access and change the database content to make the website "dynamic", such as forums and message boards. However, such programs must first be processed by the server, generate HTML pages, and then "send" them to the client, which consumes a certain amount of server resources. If you use too many such programs on the VM, the webpage display speed will be slow, so it is not necessary. Please try to use static html pages.

3. Do not insert the entire page content into a table
This is a problem with Web page design. Many webmasters put the content of the entire page into a table in pursuit of unified page alignment, then, the cell TD is used to divide the layout of each "Block". The display speed of such websites is absolutely slow. Because the table is displayed only after all the content is loaded. If some content cannot be accessed, the access speed of the whole page will be delayed. The correct method is to split the content into several tables with the same pattern. Do not add all the contents to a table.

4. Change ASP, aspx, PHP, and other files to. js references.
This should be noted in programming such as ASP, aspx, and PHP. If you want to embed dynamic data in Static HTML pages, if these dynamic data is provided by ASP, PHP, and other programs, it will be referenced using the following statement: in this way, every time someone visits your website, the server will execute and process Tongji once. ASP files, extract the corresponding data from the database, and then output the data to the web page. If tens of thousands of people access the data at the same time, tens of thousands of times are required. We recommend that you dynamically generate data to a 1. JS file, and then on the home page through the <SCRIPT src = ""> </SCRIPT> such code to reference this 1. JS file. In this way, the data display task is handed over to the browser of the client, which does not consume server resources, and the display speed is naturally very fast.

5. Use IFRAME to nest another page
If you want to insert some advertisement code on your website and do not want these websites to speed up, IFRAME is the best choice. The method is: place these ad codes on an independent page, and then embed the page with the following code on the homepage, in this way, the display of the entire homepage will not be dragged due to the delay of the advertisement page. The Code is as follows:
<IFRAME marginwidth = 0 marginheight = 0 src = "http: // www. ***. com "frameborder = 0 width = 468 scrolling = No Height = 60 leftmargin =" 0 "topmargin =" 0 "> </iframe>
Http: // www. ***. com is the path of the referenced file.

6. Website counter code placement skills
Placing a counter on a webpage can count Website access traffic and provide access basis for webmasters and advertisers. However, no matter how powerful the website statistics system is, there will be faults. If you directly put the Statistical Code in front of the page content, or put it in a table or Div label, when the counter cannot be accessed, the table or Div on your page will have a delay of dozens of seconds, resulting in a long time before the page can be accessed. Therefore, to speed up the Website, you must pay attention to the location of the statistics code. The correct method is to place the statistics code at the bottom of the page, and do not use the same table or Div label as the page content. You can directly place the Statistical Code at the bottom of the page code, or create a table or DIV at the bottom to place the counter. In this way, when the counter cannot be accessed, your website speed will not be affected at all.

7. Knowledge of friendship links
Links between websites can increase the promotion effect of websites. logo image links can more accurately describe the themes and positioning of websites. The promotion effect will be greatly enhanced, but there are too many image links, it will inevitably affect the display speed of the webpage. Many webmasters like to directly reference the image URLs on the friendship websites so that the images can only be displayed after being loaded. The access speed of each friendship website is different, the entire table can be displayed only after the image is downloaded, which greatly reduces the speed of the webpage. Therefore, we should try our best to do the following for friendship links:

1. Only text links: text links do not delay the speed of webpages.
2. Place all links on an independent page, and then click the page on the homepage link.
3. if the link must appear on the homepage, place the entire table of the link at the bottom of the page, because the page is displayed from top to bottom row by row, place it at the bottom of the page without any delay in displaying other content.
4. The logo image of the link is downloaded first and then uploaded to Your webpage space. In this way, the speed is determined by your website space and is not affected by the website space.

Bytes -----------------------------------------------------------------------------------------------------------
Reposted this article please famous Source: Just do it (

A small website, such as a personal website, can be implemented using the simplest HTML static page. With some images for beautification, all the pages are stored in a directory, such websites have very simple requirements on system architecture and performance. With the increasing diversity of Internet services, website-related technologies have been subdivided into many aspects after years of development, especially for large websites, the technology is widely used. From hardware to software, programming language, database, Webserver, firewall and other fields, there are high requirements, it is no longer comparable to a simple HTML static website.

Large websites, such as portal websites. In the face of a large number of user access and high concurrency requests, the basic solution focuses on the following aspects: use high-performance servers, high-performance databases, high-efficiency programming languages, and high-performance WEB containers. However, in addition to these aspects, it is impossible to fundamentally solve the high load and high concurrency problems faced by large websites.

The solutions provided above also mean a greater investment to a certain extent, and these solutions have bottlenecks and do not have good scalability, I will talk about some of my experiences from the perspectives of low cost, high performance, and high scalability.

1. HTML static
As we all know, the most efficient and least consumed HTML pages are purely static html pages, so we try our best to make the pages on our website adopt static pages, this simplest method is actually the most effective method. However, for websites with a large amount of content and frequent updates, we cannot manually implement them all, so we have a common information publishing system CMS, news channels such as the portals we often visit, and even other channels, are managed and implemented through the information publishing system, the information publishing system can automatically generate static pages based on the simplest information input. It can also provide channel management, permission management, automatic crawling, and other functions. For a large website, having an efficient and manageable CMS is essential.

In addition to portal and information publishing websites, static websites with high interaction requirements are also a necessary means to improve performance, static Community posts and articles in real time, and re-static updates are also a lot of use strategies, such as mop, the same is true for the Netease community.

At the same time, HTML static is also a method used by some caching policies. For applications that frequently use database queries but have little content updates in the system, you can consider using HTML static, for example, the public setting information of the Forum in the forum. Currently, mainstream forums can perform background management and store the information in the database. In fact, this information is frequently called by foreground programs, but the update frequency is very small, you can consider static content during background updates to avoid a large number of database access requests.

2. image server Separation
As we all know, for Web servers, images, whether Apache, IIS or other containers, consume the most resources. Therefore, it is necessary to separate images from pages, this is basically a strategy adopted by large websites. They all have independent image servers and even many image servers. This architecture can reduce the pressure on the server that provides page access requests, and ensure that the system does not crash due to image problems. Different configurations can be optimized on the application server and image server, for example, Apache supports as few loadmodules as possible when configuring contenttype to ensure higher system consumption and execution efficiency.

3. Database Cluster and database table hash
Large websites have complex applications, and these applications must use databases. In the face of a large number of accesses, database bottlenecks will soon become apparent. At this time, a database will soon fail to satisfy applications, therefore, we need to use a database cluster or database table hash.

In terms of database clusters, many databases have their own solutions, and Oracle and Sybase all have good solutions. The commonly used MySQL Master/Slave is also a similar solution, you can refer to the corresponding solutions to implement the database.

As the database cluster mentioned above is limited by the DB type used in terms of architecture, cost, and expansion, we need to consider improving the system architecture from the perspective of applications, database table hashing is a common and most effective solution. We install business and application or function modules in the application to separate the database. Different modules correspond to different databases or tables, then, according to a certain policy, conduct a smaller database hash for a page or function, such as a user table and table hash by user ID, in this way, the system performance can be improved at a low cost and the scalability can be improved. Sohu's Forum adopts this architecture to separate the database of Forum users, settings, posts, and other information, and then hash the databases and tables of posts and users according to sections and IDs, the simple configuration in the configuration file allows the system to add a low-cost database at any time to supplement the system performance.

4. Cache
The word cache has been used in many areas. The cache in website architecture and website development is also very important. Here we will first describe the two most basic caches. Advanced and distributed caching are described later.
For architecture caching, anyone familiar with Apache can know that Apache provides its own cache module, or use the plus squid module for caching, both methods can effectively improve Apache's access response capabilities.
The memory cache provided on Linux is a common cache interface that can be used in Web development, for example, during Java Development, you can call memorycache to cache and share data, and some large communities use this architecture. In addition, when using Web language development, various languages basically have their own cache modules and Methods. php has a pear cache module, and Java has more ,. net is not very familiar with, I believe there must be.

5. Images
Images are often used by large websites to improve performance and data security. The image technology can solve the differences in user access speed caused by different network access providers and regions, for example, the difference between Chinanet and EduNet has prompted many websites to set up image sites in CERNET to regularly update or update data in real time. In terms of image details, I will not elaborate too deeply here. There are many professional off-the-shelf solutions and product options. There are also low-cost software implementation ideas, such as rsync on Linux and other tools.

6. Server Load balancer
Server Load balancer is the ultimate solution for large websites to solve high-load access and a large number of concurrent requests.
Server Load balancer has been developing for many years. There are many professional service providers and products to choose from. I personally have some solutions, including two architectures for your reference.
Hardware layer-4 Switching
The layer-4 Exchange uses the header information of the layer-3 and layer-4 information packets to identify business flows based on the Application interval and distribute the business flows of the entire interval segment to appropriate application servers for processing. The layer-4 switching function is like a virtual IP address pointing to a physical server. Its transmission services are subject to a variety of protocols, including HTTP, FTP, NFS, telnet, or other protocols. These services require complex load balancing algorithms based on physical servers. In the IP address world, the service type is determined by the TCP or UDP port address of the terminal. The application interval in the layer-4 switch is jointly determined by the source and terminal IP addresses, TCP and UDP ports.
In the field of hardware layer-4 switching products, there are some well-known products to choose from, such as Alteon and F5. These products are expensive, but value for money, it provides excellent performance and flexible management capabilities. Yahoo China used three or four Alteon servers on nearly 2000 servers.

Layer-4 software exchange
After learning about the principle of the hardware layer-4 switch, the four-layer switch based on the OSI model came into being. Such a solution achieves the same principle, but has a poor performance. However, it is easy to meet a certain amount of pressure. Some people say that the software implementation method is actually more flexible, and the processing capability depends entirely on the familiarity of your configuration.
We can use LVS, which is commonly used in Linux for software layer-4 Switching. LVS is a Linux virtual server. It provides a real-time disaster response solution based on heartbeat to improve system robustness, at the same time, it provides flexible virtual VIP configuration and management functions to meet a variety of application needs at the same time, which is essential for distributed systems.

A typical load balancing strategy is to build a squid Cluster Based on layer-4 software or hardware exchanges. This idea is adopted on many large websites, including search engines, this architecture is low-cost, high-performance, and highly scalable. It is easy to increase or decrease nodes in the architecture at any time. I have prepared a special detail for this architecture and will discuss it with you.

For large websites, each method mentioned above may be used at the same time. I will introduce it more easily here. You need to be familiar with and understand many details during the implementation process, sometimes a very small squid parameter or Apache parameter setting will have a great impact on the system performance. I hope you can discuss it together to make it easier.

Bytes ----------------------------------------------------------------------------------------------------------
General method:
1. Use ACDSee to compress images
2. pagination: Make one page into multiple
3. do not include all graphs and Flash files in the same table, because IE will download all the content in a table before it is displayed. You can put it in multiple tables, the download will display one.
4. Change the server's fast space

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: 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.