计算机科学 ›› 2024, Vol. 51 ›› Issue (6): 346-353.doi: 10.11896/jsjkx.231100125

• 计算机网络 • 上一篇    下一篇

基于微服务的预分配额度限流设计研究

郑旭1, 范红杰2, 柳军飞3   

  1. 1 北京大学软件与微电子学院 北京 100871
    2 中国政法大学科学技术教学部 北京 102249
    3 北京大学软件工程国家工程研究中心 北京 100871
  • 收稿日期:2023-11-19 修回日期:2024-03-25 出版日期:2024-06-15 发布日期:2024-06-05
  • 通讯作者: 范红杰(hjfan@cupl.edu.cn)
  • 作者简介:(1901210850@pku.edu.cn)
  • 基金资助:
    长沙市科技重大专项项目(kh2202006)

Pre-allocated Capacity Quota Limiting System Based on Microservice

ZHENG Xu1, FAN Hongjie2, LIU Junfei3   

  1. 1 School of Software and Microelectronics,Peking University,Beijing 100871,China
    2 Department of Science and Technology Teaching,China University of Political Science and Law,Beijing 102249,China
    3 National Engineering Research Center for Software Engineering,Peking University,Beijing 100871,China
  • Received:2023-11-19 Revised:2024-03-25 Online:2024-06-15 Published:2024-06-05
  • About author:ZHENG Xu,born in 1993,master.His main research interests include software engineering and microservice.
    FAN Hongjie,born in 1984,Ph.D,associate professor.His main research in-terests include data mining and so on.
  • Supported by:
    Major Special Funds of the Changsha Scientific and Technological Project(kh2202006).

摘要: 在分布式架构下,同时存在于多个节点的限流器需要很好地协作才能达到单体限流的效果。 在真实的业务场景中,线上请求分布不规律,线下业务吞吐量大。在此情况下,某一些关键节点因为超负荷运作而响应缓慢,从而导致请求链路整体的延迟增加,甚至造成整个应用的反应迟缓。针对现有微服务限流所存在的问题,文中提出了一种基于预分配额度进行主动推送配额更新的限流算法。该算法采用服务器主动向客户端广播的模式,服务器既可以接受客户端请求,也可以主动更新持有该资源配额的节点在处理请求后的最新结果。在服务器端分配所有节点配额时,可以采用灵活的分配算法进行分配。在估算限流节点配额时,采用滑动窗口的模式记录下一段时间内的请求数量和拥有的资源配额,通过自定义的算法来预估下一个周期的配额。同时,文中基于该算法实现了一个限流模型。实验结果证明,该模型可以及时地响应配额的变化,很好地实现节点之间的公平性。相比Doorman系统,所提模型可以更好地适应线上线下流量场景和精准限流。

关键词: 限流, 微服务, 令牌桶, 推送机制, 分布式系统

Abstract: In a distributed architecture,rate limiters that exist simultaneously on multiple nodes need to collaborate effectively to achieve the same effect as a monolithic rate limiter.In real-world business scenarios,there is irregular distribution of online requests and high offline business throughput.In such cases,certain critical nodes operating under overload conditions can result in slow response times,leading to increased overall latency in the request chain and even causing sluggish application performance.To address the issues of existing microservice flow limiting,this paper proposes a rate limiting algorithm based on proactive quota updates using pre-allocated quotas.This algorithm adopts a server-initiated broadcast approach where the server can both accept client requests and proactively update the latest results for processing requests on the nodes holding the resource quotas.Flexible allocation algorithms can be utilized during quota allocation at the server end.Estimation of rate limiter quotas involves sliding window pattern to track the number of requests and the allocated resource quotas over a period of time.Additionally,we implement a rate limiting model based on this algorithm.Experimental results demonstrate that the model can promptly respond to quota changes and effectively achieve fairness among nodes.Compared to the Doorman system,the proposed model is better suited for online and offline traffic scenarios and enables more precise rate limiting.

Key words: Quota limiting, Microservice, Token bucket, Push mechanism, Distributed system

中图分类号: 

  • TP391.4
[1]ALSHUQUYRAN N,ALI N,EVANS R.A systematic mapping study in microservice architecture[C]//2016 IEEE 9th International Conference on Service-Oriented Computing and Applications.IEEE,2016:44-51.
[2]SHANG P M,CHEN Y F,YEN C,et al.Using service depen-dency graph to analyze and test microservices[C]//2018 IEEE 42nd Annual Computer Software and Applications Conference.2018:81-86.
[3]PATIL R Y,RAGHA L.A rate limiting mechanism for defending against flooding based distributed denial of service attack[C]//2011 World Congress on Information and Communication Technologies.IEEE,2011:182-186.
[4]VISSER J.YouTube Doorman[EB/OL].[2015-01-03].ht-tps://github.com/youtube/doorman.
[5]TEAM T P.Polaris Mesh[EB/OL].https://polarismesh.cn/zh/doc/%E5%8C%97 %E6%9E%81%E6%98%9F%E6%98%AF%E4%BB%80%E4%B9%88/%E7%AE%80%E4%BB%8B.html.
[6]WANG T,ZHANG W B,XU J W,et al.A survey of fault detection for distributed software systems with statistical monitoring in cloud computing[J].Chinese Journal of Computers,2017,40(2):397-413.
[7]LI S S,RONG G P,GAO Q Y,et al.Optimized dataflow-driven approach for microservices-oriented decomposition[J].Journal of Software,2021,32(5):1284-1301.
[8]ALESSANDRA L,RICARDO T,MARCO T V.Towards atechnique for extracting microservices from monolithic enterprise Systems[C]//2016 Conference on Brazilian Workshop on Software Visualization,Evolution and Maintenance.2016,97-104.
[9]ZHU H Q,MA W B,ZHOU H H,et al.Microservices user requests allocation strategy based on improved multi-objective evo-lutionary algorithms[J].Computer Science,2021,48(10):343-350.
[10]YANG Q L,JIANG L Y.Study on load balancing algorithm of microservices based on machine learning[J].Computer Science,2023,50(5):313-321.
[11]JIANG Z,WANG J L,CAO R H,et al.Method of service decomposition based on microservice architecture[J].Computer Science,2021,48(12):17-23.
[12]BARTKOV M,BOROVIKOV D.Selection of a suitable algorithm for the implementation of rate limiter based on bucket4j[J].International Journal of Online & Biomedical Engineering,2022,16(4):52-63.
[13]AHMADVAND H,DARGAHI T,FOROUTAN F,et al.Bigdata processing at the edge with data skew aware resource allocation[C]//2021 IEEE Conference on Network Function Virtua-lization and Software Defined Networks.2021:81-86.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!