Editor's note: This article, published by Blackboard (account Id:taosay) of the Weibo public account, was issued on September 17, 2013 by the Attorney-General, who has shared the reader with the Infoq Chinese station in the form of Bowen. Although this article is a personal website optimization experience, but a lot of experience and not limited to the personal site business scene, for all types of Web site maintenance personnel have reference value.
Some time ago finally make room to put the Taosay.net website to tidy up a bit, use this to share a little experience to everybody. These experiences are the basic things, mainly let the friends who are interested in the construction station can take a little detour.
First of all, my personal site taosay.net is built with WordPress, this is a set of open source blog system. Why use WordPress to build it? Because WordPress is already the world's largest open source blog system, the core code security has been greatly improved, in recent years, the major vulnerabilities are in the Third-party developers write Plug-ins, rather than the core code. WordPress has a large number of plug-ins to choose from, you can not write the code in the case of the completion of most of the site optimization work, so in the case of limited energy, is the first choice for personal building stations.
about how to buy a server, build a database, webserver, install WordPress and other content, you can refer to Mactalk written "amusing personal build Station" a article. Today, I want to write, mainly in the site after the establishment of how to optimize things.
About Performance
My site taosay.net since the line, crashed several times, because of sudden traffic surge. More typical is the "Chinese Hacker Legends" series of articles written out, aroused great concern. Web site Concurrent online number of large increase in the consequences, the first is that the database cannot carry. Because the performance of Nginx itself is very good, can support tens of thousands of concurrency, so the bottleneck is mainly on the database.
Therefore, optimizing the database connection is the first step. Common practice is to use memory to do cache, the contents of the database in advance to read into memory, the user requests, not directly read the database, but read the data in memory, thereby easing the pressure of the database. The cache software used in the past is memcached, now it is more popular redis. Both are stored in memory in the form of key-value data.
On the Internet to find an introduction to follow the hint configuration, the process I will not repeat. Note that memcached ports need to be restricted because they are generally not authenticated and can read data as long as they are connected. Many big internet companies, such as Sohu and Sina, have caused information leaks because they have not restricted the access to the ports of the caching service.
Install good memcached, then go to the WordPress plugin list, select Search "cache", or "memcache" such keywords, you can find a lot of relevant plug-ins. According to the instructions to install these plug-ins, the general can seamlessly connect the cache software and WordPress. My own solution is to memcached with WP-FFPC Plug-ins.
But then I found that wp-ffpc this plugin and other plug-ins have conflict, so temporarily deactivated, and instead of the other optimization scheme.
As mentioned earlier, the bottleneck is mainly in the database, hard disk IO is not a big bottleneck, and the number of concurrent nginx is very high, so we have an optimization method is to all the articles, generate a static HTML file, so that when users visit, also do not need to read the database directly, Instead, read the static HTML page from the hard drive. I used a call WP Super CACHE plugin to complete this work.
But the real speed of the Web site to improve, there is a more important way, is the use of CDN, the site's static files are cached to the CDN service provider network, so as to achieve acceleration. CDN's full name is "Content distribution network", the principle is to use caching technology, some files are cached in the CDN nodes all over the country, so that users of the site without access to the server, directly from the nearest node to get content. The current use of CDN has become a standard configuration for large and medium-sized Internet companies.
There are two main benefits of using CDN, one is the picture, JS, CSS, Flash and other static resources will consume 80% of the Web site traffic, the use of CDN, the 80% of the traffic will be saved, thereby easing the bandwidth consumption of their own servers; the second is the site users will be in the nearest CDN node direct access to static resources, Without access to the server source station-for example, Hunan Telecom users from the CDN in Hunan Telecom node to get pictures, JS, CSS, and so on, without having to visit the source station in the United States-so that the entire Web site access speed of 80% or so to improve.
Two 80% are empirical data, but also sorta, the specific optimization effect is good, need to see according to the actual situation. Because Doug's site has not been recorded and cannot be put into the country, the best option is to have an acceleration in Hong Kong. Hong Kong to provide accelerated service is not many, the elder brother is using his company's free products, on the one hand does not need to spend money, but also to solve the problem of hacker attacks, on the other hand can experience the company's products at any time, when the problem can be the first to kill product managers and research and In order to avoid advertising suspicion, will not repeat.
Smart readers may have thought, I used to optimize the method of each article to static into an HTML file, but also can be put into CDN network acceleration, will make your website speed like flying.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/Skills/
Because Doug is lazy, so the HTML page acceleration work has not been done. Also because of laziness, these optimizations I dragged for several months to toss, this is because the site is not profitable reasons.
In addition to the work described above, you can also consider using cloud storage as needed. WordPress has some plug-ins to support cloud storage, so you can take up the largest amount of hard disk space, such as the picture to save the content to the cloud storage, and not occupy the local hard disk space. Some cloud storage also comes with a CDN function. At present, the domestic more popular cloud storage has to shoot clouds, seven cows, Aliyun OSS and so on.
Doug's site has been expanded once a hard drive, and now the use of hard disk has been to 99%. But still because of laziness, Doug has not yet to toss cloud storage things, and so on when the site because the hard disk use 100% hang after.
Other side corners of the thing
Anti-spam comments can be used with WordPress default Akismet plug-ins, which is a more successful in the world of a anti-spam company.
Anti-hacker intrusion can consider the use of cloud WAF products, representative of my company security treasure, several competitors can also consider. Because WordPress function is relatively single, the main problem is the place or plug-in, with the cloud WAF completely enough. Remember to give your administrator account set a strong password, the background directly by hackers with large data to find the administrator password and the case is black a lot.
Server monitoring can use the domestic start-up companies "monitoring treasure", free service has been fully enough. Or dnspod launched the "D monitoring", the same free and easy to use. In addition DNS resolution must use DNSPOD, service quality is the world's leading. If the site is big enough to use many of its advanced features.
= = = The blackboard of the elder brother = =
Micro Bo Id:aullik5
Historical articles stored in: http://taosay.net