- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- 复制
- 微信扫一扫分享
- 已成功复制到剪贴板
周小四-Design Patterns Container
展开查看详情
1 .QingCloud
2 .
3 .
4 .Agenda • Introduction • Single-node patterns • Multi-node patterns • Batch processing patterns
5 .Introduction • The development of containers and container orchestrators has fundamentally changed distributed system development. • Patterns make the distributed systems easier to debug, design and architect. • Need new patterns to build reliable, scalable, reusable, efficient distributed systems. • Prereq: Docker, Kubernetes, microservice • Reference: Designing Distributed Systems, Brendan Burns
6 .Single-Node Patterns • Sidecar • Ambassador • Adapter
7 .Sidecar • Add HTTPS to a legacy service • Dynamic configuration • Istio - envoy
8 .Hands On: Deploying the topz Container • A monitoring example: $ docker run -d tomcat:9 $ docker run —pid=container:<tomcat container id> -p 9080:9080 brendanburns/ topz:db0fa58 /server --addr=0.0.0.0:9080 • http://localhost:9080/topz • http://localhost:9080/topz
9 .Building a simple PaaS with sidecar • Complete application in modular manner • Our websites • http://localhost:9080/topz
10 .Sidecar • Common usage: adapt legacy applications where you no longer wanted to make modifications to the original source code • Modularity and reuse of the components used as sidecars • Utility container • Examples: (adapting, augment/extend)
11 .Sidecar - Focus and Discipline • To achieve modularity and reusability • Parameterizing your containers • Environment variable: • Command line • API surface • Documentation (Dockerfile)
12 .Ambassador • Broker
13 .Using Ambassador for Service brokering • Brokering services on public cloud (SaaS), private cloud, or BM.
14 .Using Ambassador to Shard Service • Client-side ambassador • Server-side ambassador
15 .Using Ambassador to Do Experimentation or Request Splitting
16 .Adapter • Monitor • Normalize • Health monitor • Logging • Redirect to stdout • Transform data into a single structured representation that can be consumed by generic log aggregator. Ex. Normalizing Different Logging Formats with Fluentd
17 .Single-Node Patterns Summary • Sidecar: extend and augment existing application containers • Ambassador: alter and broker how an application container communicates with the external world • Adapter: modify the interface of the application container so that it conforms to some predefined interface that is expected of all applications
18 .Serving Patterns • Multi-node, distributed • Including: • Replicated LB services • Sharded services • Scatter / Gather • FaaS • Ownership Election
19 .Warm-up: Mircroservice
20 .Replicated Load-Balanced Services • K8S service
21 .Sharded Services • Replicated services are generally used for building stateless services, whereas sharded services are generally used for building stateful services. • Replicated, sharded service • Ex. Consistent HTTP Sharding Proxy
22 .Scatter / Gather • In contrast to replicated and sharded systems, with scatter/gather requests are simultaneously farmed out to all of the replicas in the system • Can be seen as sharding the computation to serve the request, rather than sharding the data (although data sharding may be part of it as well)
23 .Example: Distributed Document Search
24 .Scaling Scatter / Gather for Reliability and Scale • Increased parallelism doesn’t always speed things up because of overhead on each node. • Increased parallelism doesn’t always speed things up because of the straggler problem. • The performance of the 99th percentile is more important than in other systems because each user request actually becomes numerous requests to the service.
25 .Multi-Node Patterns Summary • Replicated LB services: stateless replicated pattern, scalability in terms of rps, reliability • Sharded services: sharded data pattern, scalability for the size of the data • Scatter / Gather: scalability in terms of time, parallelism
26 .Batch Processing • Work Queue • Event-driven • Coordinated
27 .Work Queue File-based API pattern
28 .Work Queue Great for enabling individual transformations of one input to one output Ex. Implementing a Video Thumbnailer
29 .Work Queue