ArticleDirectory
- 1. Where can I find the load balancing configuration page?
- 2. port forwarding Configuration
- 3. Health Check
- 4. Other problems
Recently, the company wants to migrate its architecture to the cloud, store it in S3, and use EC2 for servers. To make our architecture horizontally scalable, we use AWS Load Balancing for load balancing. In short, Server Load balancer refers to distributing a large number of client accesses to different backend Amazon EC2 instances.
Amazon's load balancing configuration is also very simple, that is, adding existing EC2 instances to load balancing. Then you can configure port forwarding to forward the port accessed by the customer to the appropriate background service. Of course, there are also some notes:
1. Where can I find the load balancing configuration page?
You can find the load balancing configuration page in your EC2 dashboard.
2. port forwarding Configuration
Before using load balancing, you must set port forwarding in the listeners tab. If you use HTTP, you can select HTTP. If you are a TCP application, select TCP. The TCP port that can be used on the forum starts from 1024. If you select HTTP, there is an option stickiness that may be useful to the application. In fact, Load balancer adds a cookie to the HTTP protocol to implement the session function.
3. Health Check
Another feature of load balancing, or feature, is that Load balancer maintains an EC2 instances pool. Instances that pass the health check are added to the instances pool to wait for the connections distributed by the Load balancer. If an instance does not pass the health check, it will be deleted from the instances pool, and the Load balancer will not distribute connections to this instance. However, the deleted instance will continue to perform health check. when it passes the health check again, it will be added to the instances pool again.
Health check can be divided into two types:
1. for HTTP applications, health check is used to access a fixed URL. If the returned HTTP status code is 200. Load balancer considers it to pass health check. You can log on to the URL server based on your business.CodeCheck the status of some servers, but it does not take too much time.
2. For TCP applications, health check initiates a TCP connections. If the connection is successful, health check is passed.
Here, timeout is the maximum timeout time for accessing the URL or TCP connection. If no response is returned within this time period (10 s), it is considered as unhealthy.
How often does interval access this URL or initiate a TCP connection. Is 300 s (5 min), which is also the maximum allowed value.
Unhealthy threshold refers to the number of consecutive access failures before this instance is removed from the instances pool.
Healthy threshold is the number of consecutive successful accesses before this instance is added to the instances pool again.
4. Other problems
Currently, a big problem for our applications is how to correctly upload the files generated by each instance to a specific location in S3. This leads to the essence of Load Balancing: multiple servers provide services at the backend. This is no problem for some applications. As long as the backend data has a unified access interface, this is not a problem. However, some applications still need to be adjusted in the architecture to achieve load balancing transparency. Make sure that transparency makes horizontal scaling easy. This is also the original intention of using load balancing.