In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "what is the difference between varnish, squid, apache and nginx". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. the difference between varnish, squid, apache and nginx
1. From these functions. Varnish and squid are professional cache services, while apache,nginx is done by third-party modules.
2. If we want to do cache services, we definitely have to choose professional cache services, giving priority to squid and varnish.
The technical advantage of varnish itself is higher than that of squid. It uses the "visual page cache" technology. In the use of memory, varnish has an advantage over squid. It avoids squid frequently swapping files in memory and disk, and its performance is higher than squid. Varnish cannot be cache to the local hard drive.
There is also a powerful management port through varnish, which can use regular expressions to quickly and bulk clear part of the cache.
The advantage of squid lies in the complete and huge technical data of cache, and a lot of application production environment (this should be related to the early emergence of squid).
3, talk about nginx,nginx is a third-party module ncache to do the buffer, its performance is basically varnish, but in the architecture nginx is generally used as a reverse (static files now use nginx a lot, and can support up to 20 +). In a static architecture, if the front end is directly faced with the four layers of load on the cdn front end, it is sufficient to use nginx's cache completely.
4. I think it is possible to do some local cache if you are improving the performance of apache services, but if you use apache to do cache services in the system architecture, it will be a bit off the mark.
Second, test varnish, squid, apache, nginx
First, the test environment
1, the hardware is Pentium dual-core, the machine bought three years ago. The system is archlinux
2. The apache used by the web service when testing varnish and squid
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
5When you access the image, you have to use the caching tool first.
Second, testing
1,varnish
The copy code is as follows:
[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.
The cache efficiency hit rate of varnish is really high.
2,squid
The copy code is as follows:
[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.
In terms of test results, squid let me down. Before testing, I estimated in my mind 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 normally, the ratio of cached to uncached is not 1:2, and under high stress, the cached / uncached ratio is even smaller.
3,apache
The copy code is as follows:
[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/rwgowetwvcqaaaaaaaawhh0rklg81.gif
100 clients, running 20 sec.
Speed=160890 pages/min, 15856005 bytes/sec.
Requests: 53630 susceed, 0 failed.
4,nginx
The copy code is as follows:
[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/rwgowetwvcqaaaaaaaawhh0rklg81.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 little different from what we expected, because how could squid be so bad as an established file caching tool? the hit rate of squid is low.
Varnish is a high-performance open source http accelerator, which is generally used with nginx, apache and so on to build an efficient web server. A thread in varnish that is responsible for accepting a new http connection starts waiting for the user, and if a new http connection comes through, it is always responsible for receiving and then waking up a waiting thread.
The worker thread reads the uri of the http request, looks for the existing object, and returns and replies to the user directly if it is hit. If you don't hit, you need to take the requested content from the back-end server, store it in the cache, and then reply. Varnish creates a cache file of the appropriate size based on the size of the object read.
According to the official statement, varnish is a cachetype http reverse Dai, varnish creates cache files according to request, if there is a timeout thread, detects the lifetime of all object in the cache, deletes it if the super-set ttl (time to live) is not accessed, and releases the corresponding structure and storage memory.
From all aspects of data, varnish has a stronger ability to handle web requests than squid, apache, etc., using varnish can greatly improve your web server and reduce the load of web server.
This is the end of the content of "what's the difference between varnish, squid, apache and nginx". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 203
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.