Architecture

Design Pattern

设计模式的目标是:封装变化,其中必然会用到接口+多态!

更多

Software Engineering

Software Engineering

http://www.uml.org.cn/oobject/OObject.asp
http://www.xin3721.com/eschool/rjgcjc/

UML: Unified Modeling Language


软件需求

需求分析 ➕ 需求定义 ➡️ 快速原型 ➡️ 需求说明书

更多

Project Management

每个人可能都有这样的经历:

flowchart LR
    A(["买运动鞋"]) -- "用一般的价格" --> B("只要穿上就不舒服") --> C("穿一年就坏")
    C --> D{"新的一年?"} -- Yes --> A

这与剃须刀原理一样: 好用的东西往往初期成本高, 但总体成本低且带来了长期优势…

更多

SOA

terminologydescriptionmemo
SaaSSoftware as a Service给客户提供网络服务程序:使客户可以通过瘦客户端直接显示界面,比如在线的’Google Docs’. 面向普通大众.
PaaSPlatform给客户的程序提供运行环境,包括:网络、服务器硬件、操作系统、存储等.客户可以自由控制自己的程序和托管环境. 面向软件开发者.
IaaSInfrastructureOpenStack、AmazonEC2
ESBEnterprise Service Bus
SOAService Oriented Architecture

Distributed

  • 分布式是为了去中心化, 降低服务程序之间的耦合. – 合久必分
  • 它是一个按业务拆分成独立的进程, 分布在不同的地方, 每个构成一个节点, 节点间通过网络沟通. 其中每个node都可以单独做集群.
  • 为了规范统一及扩展性,一般服务器之间的通讯使用RESTful标准. 服务器一般是无状态的(可使用Redis共享). 对外服务的service一般叫Gateway!

Cluster

其对外表现通常为一个服务器. – 分久必合

更多

Nginx

Engine X

由俄罗斯程序员 Igor Sysoev2004 发布

可以作为 web服务器、反向代理服务器、邮件服务器、负载均衡服务器

更多

Architecture

在软件开发中有一句名言:过早优化是万恶之源!(Premature optimization is the root of all evil)

更多

Docker

image = {|bootfs|rootfs|app...(*COW*)|} --> Container

https://github.com/yeasy/docker_practice
https://yeasy.gitbooks.io/docker_practice/content/

  • Container进程运行在自己的namespaces(proc,net,kernel,mnt的隔离)
  • os使用cgroup来实现资源的管理

install

https://docs.docker.com/engine/install/centos/
https://docs.docker.com/compose/install/

更多

Consul

Introduce

http://www.liangxiansen.cn/2017/04/06/consul/
http://thesecretlivesofdata.com/raft/

Raft

一套算法,用于解决分布式系统中数据状态的一致性.与其平行的是Paxos算法.

更多

Krakend

https://www.krakend.io/
https://github.com/devopsfaith/krakend-examples
https://github.com/devopsfaith/krakendesigner

{
  "version": 2,
  "name": "",
  "port": 8000,
  "timeout": "3s",  // 也可放在endpoint中,单独限制
  "tls": {
    "public_key": "/path/to/cert.pem",
    "private_key": "/path/to/key.pem"
  }
  "endpoints": [
    "endpoint": "/api/v1/foo-bar",
    "method": "GET",
    "timeout": "800ms",
    "concurrent_calls": 3,  // 一般不配置,和负载host两码事,这是并发向一个后端请求,择其快者
    "headers_to_pass": ["Authorization", "Content-Type"]
    "extra_config": {
      "maxRate": 5000, // ==0不限制!针对该endpoint的qps
      "clientMaxRate": 0,  // ==0不限制!针对每一个client(ip)的qps
      "strategy": "header",  // 默认按照ip来区分client

      "key": "X-Auth-Token"  // 按照header中的该key来鉴定一个client
    },
    "headers_to_pass": [ // 向下游传递哪些Headers,"*"表所有
      "Cookies"  // 默认传递"Host","User-Agent","Accept-Encoding","X-Forward-For
    ],
    "querystring_params":[ // 向下游传递哪些请求参数
      "a", "b"  // 只是指定那些key的参数可以向后传递,若实际没有传递则还是没有; "*"表传递所有
    ]
    // 添加多个backend会自动merge
    // header中指示是否全部完成: X-Krakend-Completed: false
    "backend": [
      {
        "url_pattern": "/users/{user}?name={name}"  // /users/1?name=lei,强制带参数,否则返回404.除非指定querystring,此时可不指定name(自动使用前面的值)
        "host": ["http://127.0.0.1:8000"],
        "encoding": "json",  // 改变原来的编码格式,xml,rss
        "group": "newkeyname",  // merge时作为rsp中一个单独的keyname
        "target": "data",  // 剥离原返回中的data键,里面的value作为根
        "mapping": {
          "email": "personal_email"  // 修该rsp中的key
        }
      }
      {
        "url_pattern": "/foo",
        "extra_config": {
          "github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
            "interval": 60,  // 60s后端调用失败4次,后面的所有调用都延迟10s
            "maxErrors": 4,  // 当有任何一次成功时,线路恢复
            "timeout": 10,
            "logStatusChange": true
          },
          "github.com/devopsfaith/krakend/proxy": {
            "shadow": true  // 方便新接口线上测试,会copy一份req,当并不会rsp给client
          }
        }
      }
    ]
  ]
}

更多

Gateway

istio/Envoy

https://github.com/envoyproxy/envoy
https://www.envoyproxy.io/

  • 服务网格,流量控制,istio也集成了网关的能力(南北流量控制)
  • mesh的主要着力点还是东西流量控制(服务间流量)
  • 支持ws,http2,gRPC代理; 较Nginx效率更高些

traefik 39.2k

https://github.com/traefik/traefik

更多