APP下载

面向微服务架构的负载均衡算法综述

2021-06-28陈宇明陈琳陆正武

电脑知识与技术 2021年10期

陈宇明 陈琳 陆正武

摘要:随着互联网技术的发展,传统的单体架构应用不能适应现有的互联网环境,越来越多的企业采用微服务架构来作为解决方案,而在微服务架构中如何保持各服务器的负载相对均衡是亟待解决的问题,现在解决问题的办法是通过负载均衡算法来平衡微服务架构中各服务器的负载,保持系统的高可用性。本文首先介绍了微服务框架及其相关框架,详细介绍了Spring Cloud框架的工作原理,然后分析了加权最小连接数算法、加权轮询算法等负载均衡算法。

关键词:微服务架构;Spring Cloud;负载均衡;加权最小连接数算法;加权轮询算法

中图分类号:TP31        文献标识码:A

文章编号:1009-3044(2021)10-0187-02

Abstract:With the development of Internet technology, traditional monolithic architecture applications cannot adapt to the existing Internet environment. More and more companies adopt microservice architecture as solutions, but how to keep the load of each server relatively balanced in the microservice architecture It is an urgent problem to be solved. At present, the load balancing algorithm is used to balance the load of each server in the microservice architecture to maintain the high availability of the system. This article first introduced the microservice framework and its related frameworks, detailed the working principle of the Spring Cloud framework, and then analyzed load balancing algorithms such as the weighted least connection algorithm and the weighted round-robin algorithm.

Key words: Microservice architecture; Spring Cloud; load balancing; weighted least connection algorithm; weighted round-robin algorithm

1 引言

傳统的IT行业软件多数是由各种独立系统组成,这些系统将所有功能都包含在一个独立单元的应用程序内,即单体架构应用。单体架构应用在面对用户需求快速变化的互联网环境时,出现了扩展性差、可靠性低、维护成本高等问题,许多软件或者应用开始采用微服务架构。与传统单体架构相比,微服务架构具有高维护性、高扩展性、高适应性、去中心化管理等特点[1-4]。微服务架构是将功能复杂的软件或应用划分为一组相对较小且独立的功能单元,并使用多个独立的服务来开发这些功能单元,每个服务单独运行在各自的进程。随着数据和访问量的增加,单台服务器无法满足海量的数据处理请求,无法适应实际的市场需求,为了处理并发的数据存取请求和用户访问请求,需要多台服务器同时在运行的状态,并且通过负载均衡算法将来自客户端或其他位置的请求分配给合适的服务器。……

登录APP查看全文