Talk about the comparison of varnish, squid, apache, nginx cache

http://www.cnblogs.com/google4y/archive/2011/09/19/2181251.html

There are always people in the group asking what cache is used for, there are varnish, squid, apache, nginx, etc. What are we using? What architecture cache.

1. From these functions. Varnish and squid are professional cache services, while apache and nginx are completed by third-party modules.

2. If we want to do cache service, we must choose professional cache service, prefer squid and varnish.

Varnish's own technical advantages are higher than Squid. It adopts "Visual Page Cache" technology. Varnish has advantages over Squid in terms of memory utilization. It avoids Squid frequently swapping files in memory and disk, and its performance is better than Squid. high. Varnish cannot cache to the local hard disk.

There is also a powerful management port through Varnish, which can use regular expressions to quickly and batch clear some caches

. The advantage of squid lies in the complete and huge cache technical data, and many application production environments (this should be related to the early release of squid).

3. Talking about nginx, nginx is a buffer made by the third-party module ncache, and its performance basically reaches Varnish, but in the architecture, nginx is generally used as the reverse (a lot of static files use nginx now, and the concurrency can support 20,000+). In the static architecture, if the front end is directly facing the CDN and the front end has 4 layers of load, it is enough to use the nginx cache completely.

4. I think that if it is to improve the performance of the apache service, it is completely possible to do some local caches, but if you use apache as the cache service in the system architecture, it will be a bit wrong.

---------------------------------------

The following is a reprint of a classmate's test data

1 . Test environment

1, the hardware is Pentium dual-core, the machine was bought three years ago. The system is archlinux

2. When testing varnish and squid, the web service uses apache

3. When testing apache, 5 processes are started, but as the pressure increases, the process will increase.

4. When testing nginx, ten nginx processes and 20 php-cgi processes were started.

5, varnish, squid, and nginx use the reverse proxy situation, that is to say, when accessing pictures, you must first pass the caching tool

Two, test

1, varnish

[root@BlackGhost bin]# /usr/local/bin/webbench -c 100 -t 20 http://127.0.0.1:8080/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://127.0.0.1:8080/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
100 clients, running 20 sec.

Speed=476508 pages/min, 47258114 bytes/sec.
Requests: 158836 susceed, 0 failed.

Varnish's cache efficiency hit rate is really high, see the picture below:

varnish
Varnish

has visited so many times, only once without cache, the efficiency is really high high.

2. squid

[root@BlackGhost bin]# /usr/local/bin/webbench -c 100 -t 20 http://localhost:9000/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://localhost:9000/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
100 clients, running 20 sec.

Speed=133794 pages/min, 7475018 bytes/sec.
Requests: 44598 susceed, 0 failed.

From the test effect, squid disappointed me. Before the test, I estimated in my heart that the best cache is varnish, followed by squid, then nginx, and finally apache. Now, squid is the worst . Later I looked at the log file and found that under normal circumstances, the ratio of cache to no cache is not 1:2, if under high pressure, the ratio of cache to no cache is even smaller.

3. apache

[root@BlackGhost conf]# /usr/local/bin/webbench -c 100 -t 20 http://localhost/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997 -2004, GPL Open Source Software.

Benchmarking: GET http://localhost/00/01/RwGowEtWvcQAAAAAAAWHH0Rklg81.gif
100 clients, running 20 sec.

Speed=160890 pages/min, 15856005 bytes/sec.
Requests: 53630 susceed, 0 failed .4 ,

nginx

[root@BlackGhost conf]# /usr/local/bin/webbench -c 100 -t 20 http://localhost:10000/00/01/RwGowEtWvcQAAAAAAAAWHH0Rklg81.gif
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://localhost:10000/00/01/RwGowEtWvcQAAAAAAAWHH0Rklg81.gif
100 clients, running 20 sec.

Speed=304053 pages /min, 30121517 bytes/sec.
Requests: 101351 susceed, 0 failed.

From the above test results, we can find that varnish > nginx > apache > squid, I think this result is a bit different from what everyone expected, because squid is a veteran How can the file caching tool be so bad? Squid has a low hit rate. I checked it online and many people are like this. This may be related to personal configuration. Maybe a real master can make Squid play the most power.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326996384&siteId=291194637