How to Build Distributed Concurrent System(思维草稿)

来源:互联网 发布:爱尔兰留学知乎 编辑:程序博客网 时间:2024/05/19 19:44

问题:

Distributed需要解决的问题?

fault tolerance:容错性

reliable:可靠性

scalable:伸缩性


Concurrent带来的问题?

parallelism:并发性

performance:性能



简而言之:Reactive Programming(http://www.reactivemanifesto.org/)

Reactive Systems are:

Responsive: The system responds in a timely manner if at all possible. Responsiveness is the cornerstone of usability and utility, but more than that, responsiveness means that problems may be detected quickly and dealt with effectively. Responsive systems focus on providing rapid and consistent response times, establishing reliable upper bounds so they deliver a consistent quality of service. This consistent behaviour in turn simplifies error handling, builds end user confidence, and encourages further interaction.

Resilient: The system stays responsive in the face of failure. This applies not only to highly-available, mission critical systems — any system that is not resilient will be unresponsive after a failure. Resilience is achieved by replication, containment, isolation anddelegation. Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.

Elastic: The system stays responsive under varying workload. Reactive Systems can react to changes in the input rate by increasing or decreasing the resources allocated to service these inputs. This implies designs that have no contention points or central bottlenecks, resulting in the ability to shard or replicate components and distribute inputs among them. Reactive Systems support predictive, as well as Reactive, scaling algorithms by providing relevant live performance measures. They achieveelasticity in a cost-effective way on commodity hardware and software platforms.

Message Driven: Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation, location transparency, and provides the means to delegate errors as messages. Employing explicit message-passing enables load management, elasticity, and flow control by shaping and monitoring the message queues in the system and applying back-pressure when necessary. Location transparent messaging as a means of communication makes it possible for the management of failure to work with the same constructs and semantics across a cluster or within a single host. Non-blockingcommunication allows recipients to only consume resources while active, leading to less system overhead.




Akka是如何解决这些问题的?

另外一种编程模型


问题:需要在初始化的时候做出更多的工作(这个工作具体指什么?)

收益:在扩展性上和可测试性上更容易得到保证(整体如何测试?)


和Thread Model的对比?和Distributed Objects的对比?

线程模型本身就有局限性,受限于线程的个数和资源,即使使用线程池,线程池里的线程使用完了以后,也会出现timeout。并且,使用线程模型并不会带来线性的支撑能力扩展,因为不同的线程可能会访问同一共享资源(竞争资源)。


Actor Systems

最重要的三个概念:address / mailbox / actor

最重要的四个操作:CREATE / SEND / BECOME / SUPERVISE

distributed chain of responsibility design pattern

Carl Hewitt, 1973, Erlang

runtime replacement



CAS: compare and swap


基于线程的模型和基于消息的模型

不变状态(immutability)是Message-Oriented Programming的核心。


如何对Message-Oriented Programming进行建模???




let it crash????(还有什么其他的?)







0 0
原创粉丝点击