When personal computers were just beginning to enter people's work and life, a family usually only had one computer at most. Children use computers to play games during the day, while adults use computers to fill the forum at night. But nowadays, families with only one computer are prone to situations where everyone needs to use the computer at the same time. This is more or less the same as what happened in the IT industry. Because computers have become more and more common, the demand for services and servers has increased to the point where they may go down due to overuse. Fortunately, we now have the concept of load balancing to help us deal with this demand.
What is load balancing?
Load balancing is a general term that refers to anything done to ensure that the resources you manage are allocated effectively. For network server system administrators, load balancing usually means ensuring that the network server software (such as Nginx) is configured with enough worker nodes to handle the surge of visitors. In other words, if a website suddenly becomes very popular and its number of visitors doubles within a few minutes, the software running the server must be able to react to this situation without making users feel that the visit has become not fluent. For simple sites, only simple configuration is required, but for complex sites with dynamic content and several database queries per user, this may be a difficult problem to deal with.
This problem should have been solved with the development of cloud computing, but when a network application encounters an unexpected surge, it may not be able to expand in time.
When it comes to load balancing, remember that distributed resources do not mean evenly distributed. Not all tasks always require all available resources. An intelligent load balancing strategy should only provide resources for users and anything when appropriate. Of course, this is usually handled by the development engineer rather than by the IT infrastructure department. Asynchronous applications can not occupy valuable resources on the server when the user leaves for a short time.
How load balancing works
Load balancing avoids bottlenecks by distributing the workload across multiple computing nodes. Those nodes may be physical servers in the data center, containers in the cloud, servers set up for edge computing scenarios, Java Virtual Machines in complex application frameworks, or daemons running on a single Linux server.
The specific implementation principle is to split the big problem into several small tasks, and assign a designated computer to each task. For example, for a web page that requires a user to log in, the web page may be hosted on Server A, while the login page and all authentication lookups are hosted on Server B at the same time. This deployment method can make a new user log in to the account without using resources from other active users.
Cloud load balancing
Cloud computing uses containers, so there is usually no independent physical server to handle different tasks (in fact, there are many independent servers, but they are concentrated together as a computing "brain"). On the contrary, a "pod" is created by several containers. When a pod starts to run out of resources due to its users or task load, an identical pod is generated. Storage and network resources are shared among Pods, and each pod is assigned to a computing node when it is created. Pods can be created or destroyed according to the needs of the load, so that no matter how many users there are, users can experience a consistent quality of service.
Edge computing
Edge computing needs to consider the physical world when performing load balancing. Cloud is a distributed system, but in reality, cloud nodes are usually concentrated in several data centers. The further away users are from the data center that runs the cloud, the more physical barriers they must overcome to obtain the best service. Even with fiber optic connections and proper load balancing, the response time of a server located 3000 kilometers away may be longer than that of a server 300 kilometers away.
Edge computing brings computing nodes to the "edge" of the cloud in an attempt to bridge the geographic gap, thereby forming a satellite network for the cloud, so it also plays a role in good load balancing.
What is a load balancing algorithm?
There are many strategies for load balancing, and their complexity depends on the technologies and requirements involved. Load balancing is not necessarily very complicated. Even if you use professional software such as Kubernetes or Keepalived, you must perform load balancing from the beginning.
When your application can take simple precautions by itself, don't rely on containers to balance the load. If you design your application to be modular and short-lived from the beginning, then you will benefit from the ingenious network design, container orchestration, and any future load balancing opportunities brought by technologies.
Some popular algorithms can guide your work as an application developer or network engineer, including:
- Assign tasks to servers in order (this is usually called round-robin)
- Assign tasks to the least busy server currently
- Assign tasks to the server with the best response time
- Assign tasks randomly
These principles can be combined or weighted, for example, when assigning particularly complex tasks, favor the most powerful server in a group. Orchestration is commonly used, so that the administrator does not have to tinker with perfect algorithms or strategies for load balancing, although sometimes it is up to the administrator to choose which combination of load balancing schemes to use.
Expect the unexpected
Load balancing is not really about ensuring that all your resources are used evenly throughout the network. Load balancing refers to ensuring a reliable user experience even when unexpected situations occur. A good infrastructure can withstand computer downtime, application overload, fierce attacks from network traffic, and user errors. You can start thinking about how to make the service resilient, and design the corresponding load balance from scratch.
Original link:
https://opensource.com/article/21/4/load-balancing
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。