The difference between nginx and lvs
Both lvs and nginx can be used as multi-machine load solutions. They each have their own advantages and disadvantages. In the production environment, the actual situation needs to be carefully analyzed and utilized.
Advantages of lvs:
1. Strong load resistance, because the logic of how lvs works is very simple, and It works at layer 4 of the network layer and is only used for request distribution. There is no traffic, so there is basically no need to think too much about efficiency. LVS generally rarely fails. Even if it does, it is usually caused by problems elsewhere (such as memory, CPU, etc.).
2. Configurability, this is usually a major disadvantage but also a major advantage, because there are not many configurable options, so except for adding or removing servers, you do not need to touch it often, which greatly Reduces the chance of human error.
3. Stable work, because the province has strong load resistance, so high stability is natural. In addition, various LVS have complete dual-machine hot backup solutions, so there is no need to worry about the equalizer itself. What problems may occur? If a node fails, LVS will automatically identify it, so the overall system is very stable.
4. No traffic, lvs only distributes requests, and the traffic does not go out from itself, so you can use it to do some line diversion. There is no traffic and the IO performance of the equalizer is not affected by large traffic.
5.lvs can basically support all applications. Because green work is on layer 4, it can load balance almost all applications, including http, databases, chat rooms, etc.
In addition: lvs is not completely able to identify node failures. For example, in the wlc allocation mode, if a node in the cluster is not configured with VIP, the entire cluster will be unusable. In this case, the wrr allocation method will be lost. a machine. This issue is currently still under further testing. So it’s better to be more careful when using LVS.
The results of comparison between nginx and lvs:
1.nginx works on the 7th layer of the network, so it can implement diversion strategies for the http application itself, such as For domain names, directory structures, etc., in comparison, lvs does not have such functions, so nginx can be used in far more situations than lvs based on this alone; but these useful functions of nginx make it more adjustable than LVS, so you often have to touch it. Judging from the second advantage of LVS, the more you touch it, the greater the chance of human problems.
2.nginx has less dependence on the network. In theory, as long as ping is successful and webpage access is normal, nginx can be connected. nginx can also distinguish between internal and external networks. If it is a node that has both internal and external networks , which is equivalent to a single machine having a backup line; LVS is more dependent on the network environment. At present, the server is in the same network segment and LVS uses direct mode to distribute traffic, so the effect is better guaranteed. Also note that LVS needs to apply for at least one IP from the hosting provider to be used as a visual IP. It seems that IPs from the same province cannot be used as VIP. To be a good LVS administrator, you really need to follow up and learn a lot of knowledge about network communication. It is no longer as simple as http.
3.nginx is relatively simple to install and configure, and it is also very convenient to test, because it can basically print out errors in the log. The installation, configuration, and testing of LVS take a relatively long time, because as mentioned above, LVS is highly dependent on the network. In many cases, failure to configure successfully is due to network problems rather than configuration problems. If there is a problem, it must be solved accordingly. It will be much more troublesome.
4.nginx can also withstand high loads and is stable, but the load is very poor and the stability is poor. There are several levels of lvs: nginx handles all traffic, so it is limited by machine IO and configuration; its own bugs are also It is still unavoidable; nginx does not have a ready-made dual-machine hot backup solution, so running on a single machine is still relatively risky, and it is difficult to say anything about a single machine.
5.nginx can detect internal server failures, such as status codes, timeouts, etc. returned by the server processing web pages, and will resubmit requests that return errors to another node. Currently, ldirectd in lvs can also support monitoring the internal conditions of the server, but the principle of lvs prevents it from resending requests. Regarding resending the request, for example, if the user is uploading a file, and the node processing the upload happens to fail during the upload process, nginx will switch the upload to another server for reprocessing, and lvs will be directly disconnected. If Users may be annoyed by uploading a large or important file.
6.nginx’s asynchronous processing of requests can help the node server reduce the load. If you use Apache to provide direct external services, then when there are many narrowband links, the Apache server will occupy a large amount of memory and cannot be released. Use more than one If nginx acts as an Apache proxy, these narrowband links will be blocked by nginx, and too many requests will not accumulate on Apache, thus reducing a considerable amount of memory usage. Using Squid has the same effect in this regard. Even if Squid itself is configured not to cache, it will still be of great help to Apache. LVS does not have these functions, so it cannot be compared.
nginx can also be used as a mid-level proxy. At this level, nginx has basically no rivals. The only one that can shake nginx is lighttpd. However, lighttpd is not yet able to achieve the full functions of nginx, and the configuration is not so clear and easy to read. . In addition, the IP address of the middle-level agent is also important, so having a VIP and LVS for the middle-level agent industry is the most perfect solution.
The specific application needs to be analyzed in detail. If it is a relatively small website (daily pv
For more Nginx related technical articles, please visit the Nginx usage tutorial column to learn!
The above is the detailed content of The difference between nginx and lvs. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To allow the Tomcat server to access the external network, you need to: modify the Tomcat configuration file to allow external connections. Add a firewall rule to allow access to the Tomcat server port. Create a DNS record pointing the domain name to the Tomcat server public IP. Optional: Use a reverse proxy to improve security and performance. Optional: Set up HTTPS for increased security.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

To solve the "Welcome to nginx!" error, you need to check the virtual host configuration, enable the virtual host, reload Nginx, if the virtual host configuration file cannot be found, create a default page and reload Nginx, then the error message will disappear and the website will be normal show.

There are five methods for container communication in the Docker environment: shared network, Docker Compose, network proxy, shared volume, and message queue. Depending on your isolation and security needs, choose the most appropriate communication method, such as leveraging Docker Compose to simplify connections or using a network proxy to increase isolation.

To register for phpMyAdmin, you need to first create a MySQL user and grant permissions to it, then download, install and configure phpMyAdmin, and finally log in to phpMyAdmin to manage the database.

Server deployment steps for a Node.js project: Prepare the deployment environment: obtain server access, install Node.js, set up a Git repository. Build the application: Use npm run build to generate deployable code and dependencies. Upload code to the server: via Git or File Transfer Protocol. Install dependencies: SSH into the server and use npm install to install application dependencies. Start the application: Use a command such as node index.js to start the application, or use a process manager such as pm2. Configure a reverse proxy (optional): Use a reverse proxy such as Nginx or Apache to route traffic to your application

Converting an HTML file to a URL requires a web server, which involves the following steps: Obtain a web server. Set up a web server. Upload HTML file. Create a domain name. Route the request.

Troubleshooting steps for failed phpMyAdmin installation: Check system requirements (PHP version, MySQL version, web server); enable PHP extensions (mysqli, pdo_mysql, mbstring, token_get_all); check configuration file settings (host, port, username, password); Check file permissions (directory ownership, file permissions); check firewall settings (whitelist web server ports); view error logs (/var/log/apache2/error.log or /var/log/nginx/error.log); seek Technical support (phpMyAdmin
