美文网首页
Cloud Design Pattern

Cloud Design Pattern

作者: yangweigbh | 来源:发表于2017-08-25 22:24 被阅读29次
    • 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

    相关文章

      网友评论

          本文标题:Cloud Design Pattern

          本文链接:https://www.haomeiwen.com/subject/hbnddxtx.html