Cloud Design Pattern

  • Ambassador pattern

适合多个App共享一些网络功能或者不方便修改程序加入网络功能,将网络功能放入单独的进程中

Ambassador pattern
  • Anti-Corruption Layer pattern

老系统与新系统之间加一层转换层,避免老系统污染新系统

Anti-Corruption Layer pattern
  • Backends for Frontends pattern

为移动端或者web端搭建不同的后端,可以使不同的后端为不同的前端作优化

image.png
  • Bulkhead pattern

将client请求service的资源分组,避免一类请求消耗掉所有的资源

Bulkhead pattern
  • Cache-Aside pattern

读数据时,如果缓存里没有,就从data store里读取,然后放入缓存
写数据时,写进data store,然后invalidate缓存的数据

Cache-Aside pattern
  • Circuit Breaker pattern
Circuit Breaker pattern
  • Command and Query Responsibility Segregation (CQRS) pattern

读取数据和写入数据的接口分开,读写数据的model也可以不同

Command and Query Responsibility Segregation (CQRS) pattern
  • Compensating Transaction pattern

Eventual consistency is a consistency model used in distributed computing to achieve high availability that informally guarantees that, if no new updates are made to a given data item, eventually all accesses to that item will return the last updated value

为了应对Eventual consistency model中操作失败,记录每一步的操作和恢复这一步所需的操作,如果某一步失败,可以进行回滚

Compensating Transaction pattern
  • Competing Consumers pattern

将耗时操作放到consumer中,通过发送message告知

Competing Consumers pattern
  • Compute Resource Consolidation pattern

将类似的任务放到同一运算单元中。避免运算单元资源的浪费

Compute Resource Consolidation pattern
  • Event Sourcing pattern

传统CRUD的缺点:

  1. 所有操作都在同一数据集上操作,会导致性能下降
  2. 数据更新操作有可能会冲突
  3. 没有历史数据

Event source 将对数据的操作记录到Event store中,然后通知订阅者去执行每个event对应的操作

Event Sourcing pattern
  • External Configuration Store pattern

多个应用实例要共享配置信息时,配置应该单独保存在配置服务器上

External Configuration Store pattern
  • Federated Identity pattern

用户系统应该使用外部提供的服务

Federated Identity pattern
  • Gatekeeper pattern

提供公共接口的部分和访问内部资源部分要分开,提供公共接口的部分做gatekeeper

Gatekeeper pattern
  • Gateway Aggregation pattern

如果一个客户端要请求多个backend,可以每个请求合并成一个,改善请求性能

Gateway Aggregation pattern
  • Gateway Offloading pattern

将一些公共的服务抽取到GateWay中,统一让gateway处理

Gateway Offloading pattern
  • Gateway Routing pattern

当client需要访问多个service时,让gateway充当唯一的endpoint,由gateway将请求route到对应的service

Gateway Routing pattern
  • Health Endpoint Monitoring pattern

服务应该提供一个endpoint供外部访问,提供自己的health check result

Health Endpoint Monitoring pattern
  • Index Table pattern
    对于no sql数据库,这种不支持index的数据库,可以自己创建index table
image.png
  • Leader Election pattern

在使用分布式系统进行任务处理时,需要推选一位Leader,进行任务的协调。

  • Materialized View pattern

data store中的数据可能不适合于查询,提前生成适合于查询的视图以加速查询

Materialized View pattern
  • Pipes and Filters pattern

将复杂任务分解成多个可以被复用的子任务。使得每个子任务可以独立的deploy和scale

Pipes and Filters pattern
  • Queue-Based Load Leveling pattern

用队列作为请求和处理的缓冲,以削平请求波峰

Queue-Based Load Leveling pattern
  • Retry pattern

当请求服务失败时,进行重试

  1. 取消重试: 如果错误是不可恢复的或者重试也不太可能成功的,取消重试
  2. 重试: 如果是短暂或者不常见的错误,立即重试
  3. 一定延迟后的重试:如果是服务繁忙,则在一定延迟后重试,重试间隔要使其他重试的client均匀分布,避免使本来繁忙的server更加繁忙
  • Scheduler Agent Supervisor pattern
  1. Scheduler: 协调一个task中不同step的运行,将step的状态保存到state store中。

  2. Agent: 执行远程服务连接

  3. Supervisor:监控各个step的运行状态,执行fail的step或者整个task的恢复

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • =========================================================...
    _灯火阑珊处阅读 7,124评论 0 3
  • API定义规范 本规范设计基于如下使用场景: 请求频率不是非常高:如果产品的使用周期内请求频率非常高,建议使用双通...
    有涯逐无涯阅读 7,775评论 0 6
  • 要加“m”说明是MB,否则就是KB了. -Xms:初始值 -Xmx:最大值 -Xmn:最小值 java -Xms8...
    dadong0505阅读 10,352评论 0 53
  • 如果可以不长大,就留在爸妈身边做个小孩子该多好。 可是爸妈把我养大了,我有能力担当自己的生活了,和爸妈团聚的时间也...
    思慕一生阅读 5,274评论 15 71
  • 他和我之间,究竟谁是谁的过客,谁是谁生命的点缀。 我生长在这一条名为磻溪的小河中。 磻溪说...
    杜陵塬阅读 1,711评论 0 0

友情链接更多精彩内容