Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between squid,nginx,lighttpd reverse proxies

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about the difference between squid,nginx,lighttpd reverse proxy, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

The difference of squid,nginx,lighttpd reverse proxy

Reverse proxies can be divided into two types in terms of transmission:

1: synchronous mode (apache-mod_proxy and squid)

2: asynchronous mode (lighttpd and nginx)

In the documentation of nginx, I mentioned the asynchronous transfer mode and mentioned that it can reduce the number of back-end connections and stress. Why?

The following is to explain the difference between the synchronous transmission of traditional apache/squid and the asynchronous transmission of lighttpd,nginx.

Look at the picture:

Synchronous transfer: the browser initiates a request, and then the request is immediately transferred to the background, so a channel is established between the browser and the background. This channel exists from the request initiation to the completion of the request.

Asynchronous transfer: when the browser initiates a request, the request is not immediately transferred to the background. Instead, the request data (header) is first received on the nginx, and then the nginx sends the request to the backend. After the backend processing, the data is returned to the nginx, and the nginx sends the data to the browser, which is a little different from lighttpd. Lighttpd receives the backend data completely before sending it to the browser.

Summary: the reverse of apache and squid will increase the burden on the backend web, because each user request will establish a long-term link with the backend server on the proxy, until the connection will not disappear until the data is fetched. Because of the difference between wan speed and lan speed, although the speed between lan is extremely fast, but the user's wan connection determines this long time. The asynchronous mode of lighttpd and nginx is that no matter how much data your users require, they all take it away first, and then contact the backend, which is very fast, so the connection time between proxy and the backend will be very short, and tens of megabytes of things will be within seconds. The back end does not need to maintain so many connections. Lighttpd is also different from nginx in asynchronism. Lighttpd receives the data first and then transfers it to the client browser, while nginx transfers to the user browser while receiving data.

So what are the benefits of this?

1. Suppose the user performs a file upload operation, because the user's network speed is slow, so it takes half an hour to transfer the file to the server. Squid's synchronization agent established a connection with the background after the user started uploading, and the file upload finished half an hour later, thus it can be seen that the background server connection has been maintained for half an hour. The nginx asynchronous agent first sends this file to the nginx, so only nginx maintains a connection with the user for half an hour. The backend server does not open a connection for this request within half an hour, and the user's upload ends half an hour later. The nginx sends the uploaded content to the background. There is ample bandwidth between the nginx and the backend, so it only takes one second to send the request to the background. The background server connection was maintained for one second. Synchronous transmission takes half an hour on the background server, while asynchronous transmission takes only one second, which shows a great degree of optimization.

two。 In the above example, if the background server restarts for various reasons, the upload of files will naturally be interrupted, which is a very annoying thing for users. You must also have the experience of being interrupted in the middle of uploading files. After using the nginx proxy, the impact of the restart of the backend server on user upload is reduced to the extreme, while nginx is very stable and does not need to restart it frequently. Even if it needs to be restarted, you can restart nginx continuously using kill-HUP.

3. Asynchronous transfers can make load balancers more secure. Why do you say that? In other equalizers (lvs/haproxy/apache, etc.), each request has only one chance. If the user initiates a request and the backend server to which the request is assigned just dies, then the request fails; while nginx is asynchronous, so the request can be re-sent to the next backend, and the next backend returns normal data, so the request can be successful. Let's still use the example of user uploading files. If not only nginx proxy is used, but also load balancer is used, nginx sends the uploaded file to one of the backend, but the server suddenly restarts. When nginx receives an error, it will send the uploaded file to another backend, so the user does not have to spend half an hour uploading it again.

4. If the user uploads a 10GB-sized file, and the background server does not take this situation into account, then the background server should not crash. With nginx, you can block all these things on nginx and limit them through nginx's upload file size limit. in addition, the performance of nginx is very guaranteed, so rest assured that you can let those alternative users on the Internet compete with nginx.

Using asynchronous transfer can cause problems:

If the backend server has the ability to provide upload progress, you cannot make progress with the nginx proxy, which needs to be achieved by using a third-party module of nginx.

These are the differences between squid,nginx,lighttpd reverse agents. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

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

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report