Sinsing website Architect Note Fourth

Source: Internet
Author: User

In This section we know about Web servers, and to talk about Web servers, I'm afraid I can't fail to mention the famous Apache, the same God-like server still occupies at least half of the market. Apache was originally used for small or experimental internet networks, and later gradually extended to a variety of systems, supporting Linux almost perfect. Apache can support SSL technology and support multi-state virtual hosts. And it is a process-based structure, and the process uses more system resources than threads, and therefore does not apply to multiprocessor environments.

If the site is a large number of visits, the daily log files will be very large, this time you can use the Apache rotetelogs to cut log files, cut into smaller files, the data analysis is still the same effect. I will write my own tutorial to show you, here is no nonsense.

Here are some of the more important modules of Apache. The first is the compression module, Gzip is a very popular compression algorithm, and the application is very extensive, especially on the Linux platform, when a plain text with gzip compression, you can reduce the file size of more than 70%. We can compress the content of Apache published Web pages to the user's browser by gzip, which reduces the number of bytes transmitted by the network, and the most obvious benefit is to speed up the loading of web pages. Gzip compression is generally recommended as long as the server is supported. There are two modules for compressing using the GZIP compression algorithm on Apache: Mod_gzip and Mod_deflate, to use gzip compression, you should first determine whether the server has enabled support for that component. We can look at the HTTP header to determine whether the client browser accepts gzip compression, that is, to look at the HTTP header accept-encoding This information, then the current mainstream browser is supported gzip compression. MIME type can be added according to the actual situation, for PDFs, pictures, music and other files, itself has been highly compressed, so the effect of repeated compression is not large, but may be increased by the load of the machine to reduce performance. So what's the difference between Mod_gzip and mod_deflate? The difference is mod_deflate compression speed, but the MOD_GIZP compression ratio is higher. We can also define the compression level of the mod_deflate, which is from 1 to 9, in general, the smaller the number, the faster the compression speed, the compression quality is correspondingly lower.

The second is a simple anti-DDoS attack module, in general, Mod_dosevasive is an Apache third-party optional module that can handle some HTTP-based denial-of-service attacks, commonly referred to as DDoS attacks. The module from the Apache1.3 version, it does not completely and completely prevent large-scale DDoS attacks, but for a general small and medium-sized website, it still has a certain effect. It is also very simple, that is, if a certain time period of an IP access is too fast, then directly return a 403 error.

The third is the Mod_limitipconn module, its main purpose is to prevent users of multi-threaded download, so it is easy to eat up the resources of the server, especially for some small sites, many threads simultaneously send requests, will have a large impact on the server. We can limit the number of threads that are used by the download, that is, limit the number of concurrent connections to the same IP.

And then we met Lighttpd, a German-led open-source software that was designed to provide a secure, fast, compatible, and flexible Web service environment for high-performance websites. It has a fairly low overhead, low CPU footprint, excellent performance, and a rich module, which is a great addition to many open-source, lightweight Web servers. and simply look at the function, it also supports fastcgi, CGI, auth, output compression, url rewriting, alias and other functions, in many functions lighttpd with the Apache have a fight.

Let's analyze the lighttpd, purely from the performance, first consider the relationship between single process and multi-process, multi-process server such as Apache when sending a request will wake up all the sleep process, but the end service only one, in the number of processes, This can cause a lot of trouble when the request is frequent, making the system constantly busy switching processes. The LIGHTTPD uses a single process to respond to requests, with Libevent,poll () as the event handler, if it is not using large file support and is simply a static file, performance is beyond Apache.

The main disadvantage of Apache is that in the dense concurrency state, the process needs to constantly switch, and occupy a relatively high memory, may make the system resources exhausted, and LIGHTTPD using the multiplex technology, code after optimization, the volume is very small, the resource occupancy rate is much lower, The reaction speed is also quite fast.

If it is using Apache rewrite technology, the heavy cgi/fastcgi task to lighttpd to complete, then will make full use of the advantages of both, the server load will be reduced by an order of magnitude, the reaction speed will be increased by one or even a few orders of magnitude.

As a part of the Sinsing note is written here, then I will give a tutorial on the server, I look forward to your attention AO.







Sinsing website Architect Note Fourth

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.