当前位置:网站首页>大话云原生之负载均衡篇-小饭馆客流量变大了
大话云原生之负载均衡篇-小饭馆客流量变大了
2022-07-02 22:05:00 【InfoQ】
一、前言
二、从路边摊说起
- 她的摊位很少会出现长时间的等菜的现象。因为摊位的桌椅板凳的容量通常是有限的,通常也没那么多客人,食品总的需求量的上限也基本是固定的,相对好协调。
- 沟通顺畅、快速,这头点菜点串吼一嗓子、那边就开始做上了。做好了再吼一嗓子,就上菜了。
- 短小精悍、容易掉头。夫妻俩之所以选择从路边摊开始,是因为船小好掉头。有可能干一阵发现这个位置客流少,就可以立刻停止经营或者换个地方经营。

- 能够接纳的请求数量时有限的,一是从需求上没那么多用户,二是创业公司资源限制,服务器的内存、CPU配置是有限的。
- 单体应用的视图层、控制层、持久层全都在一个应用里面,调用方便、响应快速。服务间没有远程调用RPC,响应速度更快一些,具体到某个服务请求的响应结果更快。
- 开发简单、上手快、三五个人团队好管好用。老板决定不干了,随时可以掉头,基本不太肉疼。
三、开饭馆与负载均衡
- 招什么人?当然是厨师啊、端菜收银的妻子自己还能干得过来,主要是丈夫的活挺不住了,对,那就招厨师。
- 不能让多出来的客人站着吃吧?租一个附近的门市、添置更多的桌椅板凳。
- 小夫妻两一口气为饭馆配置了三个厨师(含丈夫),这下可够用了。妻子将单号订单给张厨师、双号订单给李厨师,两人都干不过来了,再将订单给丈夫。反正外人不用白不用,自己家人能歇会就歇会。她说给谁就给谁,她有自己的一套算法。这种模式就是“客户端负载均衡”,妻子作为客户端调用“厨师”服务,会记得总共有几个厨师,然后按照自己的算法将用户请求转发给其中一个厨师。我们常见的Spring Cloud每个服务请求其他微服务的时候,都在其内部维护一个微服务列表,然后根据请求目标及算法从微服务中选择一个服务进行远程服务调用。
- 有一天这俩厨师提出意见:这么干太累了没有闲着时候,要么丈夫多出力,要么涨工资。夫妻俩一合计现在实力也不是很雄厚,还是丈夫多出力吧。那妻子也就没有必要记住“订单的单双号”了,就使用一款app输入顾客订单,该app可以实现订单的均衡分配给厨师。“这种模式就是“服务端负载均衡””。对于软件架构而言该app就是负载均衡器,常用的软件负载均衡器有nginx、haproxy等。还有一些硬件的负载均衡器,性能上要更好一些,当然收费也更“好”。架构如下图所示:

- “利”就是应用的处理能力增加了,能够处理更多的订单。
- “弊”就是沟通成本增加了,原来吼一嗓子解决的问题,现在需要靠app转发了(负载均衡器)。无论是远程服务调用,还是请求转发转发都是耗时的。
四、饭后沟通
边栏推荐
- Commodity information management system (C language document version)
- Socket套接字C/S端流程
- [shutter] shutter application theme (themedata | dynamic modification theme)
- Leetcode theme [array] -169- most elements
- [001] [arm-cortex-m3/4] internal register
- 基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
- PHP wechat red packet grabbing algorithm
- 关于PHP-数据库的 数据读取,Trying to get property 'num_rows' of non-object?
- Learn computer knowledge from scratch
- U++ learning note pile
猜你喜欢
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
Micro service gateway selection, please accept my knees!
开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
Share how to make professional hand drawn electronic maps
Socket套接字C/S端流程
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
From personal heroes to versatile developers, the era of programmer 3.0 is coming
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
Utilisation de simpletk - 4. Question étrange
An overview of the development of affective computing and understanding research
随机推荐
【微服务|Sentinel】重写sentinel的接口BlockExceptionHandler
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
关于PHP-数据库的 数据读取,Trying to get property 'num_rows' of non-object?
Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
Simpleitk use - 4 Strange question
Socket套接字C/S端流程
Pointer and string
UE4 UI自适应屏幕
U++ 学习笔记 堆
Methods of adding styles to native JS
原生js添加样式的方法
Market Research - current market situation and future development trend of third-party data platform
Market Research - current situation and future development trend of sickle cell therapy Market
Lightgbm principle and its application in astronomical data
【ODX Studio编辑PDX】-0.1-如何快速查看各Variant变体间的支持的诊断信息差异(服务,Sub-Function...)
[staff] Sibelius 7.5.1 score software installation (software download | software installation)
Market Research - current situation and future development trend of environmental friendly fireworks Market
Source code analysis - lightweight asynchronous crawler framework Ruia