这一节课,我还是提前根据公布的胶片来预习完成,等到后面再补充修改。
本节课主要是讲解分布式和云计算的架构设施。
分布式计算的概念是一堆异步网络计算机的集合,然后这些计算机内部之间通过发送消息等进行沟通,对于外部的用户来说,这看上去就像是一台电脑。每一个任务或者说进程都是由若干台计算机来共同完成的,而不是单一一台,因此这需要某些机制来对这若干台计算机进行内部协调。inter-process communication mechanisms
理解两个概念,进程process就是执行中的程序program,程序是被动的实体,就放那里,不用也不会动。而进程则是执行中的,是主动的实体,一旦开始必须执行完。每一个进程都需要调用各种资源,比如CPU,比如内存,比如网络等等,而且进程中的小任务完成后还会回收资源,用在其他或者下一个运算。一般来说,一个程序或者一个系统都包含了很多进程,这些进程都是同步运行的,一般都是通过CPU进行调度。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-7.png)
下面就要了解一下进程的管理,
进程管理有许多,比如下列的任务
• Creating and deleting both user and system processes
• Suspending 暂停 and resuming 继续 processes
• Providing mechanisms for process synchronization 同步
• Providing mechanisms for process communication 沟通
• Providing mechanisms for deadlock handling 死锁机制
这里就不得不提到五个哲学家吃饭的经典CS案例,哲学家之间只有一只筷子,每个哲学家只能吃饭和思考,吃饭时候不能思考,思考时候不能吃饭,吃饭需要两只筷子。如果防止死锁,即每个哲学家只有一只筷子,并且等待吃饭这种情况。下面的维基百科给出了一些基础的解法,可以看看。
https://zh.wikipedia.org/wiki/%E5%93%B2%E5%AD%A6%E5%AE%B6%E5%B0%B1%E9%A4%90%E9%97%AE%E9%A2%98
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-8.png)
下面就是引入了middleware中间件这个概念,这个就是在底层和应用层之间起到传递信息啊调度啊等等作用。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-9.png)
– locate applications transparently across the network;
– shield software developers from low-level, tedious 无趣的 and error-prone 易出错的 platform details;
– provide a consistent set of higher-level abstractions that are much closer to application requirements;
– leverage previous developments and reuse them;
– provide services such as reliability, availability, authentication and security.
比如上节课提到的cloud模型中,middleware就处于O/S 和Runtime/data以及应用之间。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-10.png)
而最近的趋势则是无服务化,因此middleware和API Gateway作用差不多,这个有待确认。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-11.png)
然后又讲到了经典的CS架构,举了几个例子 Ajax和CS的对比,但是感觉这还是概念性的东西。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-12.png)
inter-process communication
a就是排队处理,b则是共享内存,很明显a的效率不高。
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-13.png)
这种情况下,一侧始终是写入,另外一侧始终读取
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-14.png)
所以在分布式系统和应用通过发送信息来进行沟通,高速,异步,进程对进程之间沟通。然后呢,进程之间就是一个发送,一个接受,把结构化的数据拆碎,然后可以流媒体化传输,另外一侧再重新组装。这里有两种情况,一种是进程暂停然后发送信息,这就是synchronous message;而另外一种则是进程不停止,继续运行,同时发送信息这种就是 Asynchronous message。
Synchronous forms of middleware
RPC即 remote procedure calls,
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-15.png)
• RPC-style programming leads to tight coupling of interfaces and applications.
• In an RPC environment each application needs to know the intimate details of the interface of every other application – the number of methods it exposes & the details of each method signature it exposes.
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-16.png)
上下两者区别就是下面的异步沟通不需要应用去了解其他英勇的接口,如何到达等细节,只需要确保自己的信息发送到信息系统即可。
• Asynchronous communication promotes loose coupling in which an application does not need to know the intimate details of how to reach and interface with other applications.
• Each participant in a multi-step business process flow need only be concerned with ensuring that it can send a message to the messaging system.
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-17.png)
Asynchronous forms of middleware
这一块看的晕头转向,我估计讲课时候也不会有太好的修正。
Most asynchronous messaging mechanisms follow the “fire-and-forget” messaging principle where the sending application can conduct its work as usual once a message was asynchronously sent.
– The sending application assumes that the message will arrive safely at its destination at some point in time.
– This mode messaging does not preclude the necessity to perform request/reply operations.
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-18.png)
Publish/Subscribe Messaging
The application that produces information publishes it and all other applications that need this type of information, subscribe to it.
– Messages containing the new information are placed in a queue for each subscriber by the publishing application.
– Each application may have a dual role: it may act as a publisher or subscriber of different types of information.
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-19.png)
Event-driven processing mechanisms
事件驱动的机制
The asynchrony, heterogeneity, & inherent loose coupling that characterize modern applications in a wide-area network requires event notification mechanisms.
• Event notification offers a many-to-many communication and integration facility. Clients in an event-notification scheme are of two kinds:
– objects of interest, which are the producers of notifications, &
– interested parties, which are the consumers of notifications.
• A client can act as both an object of interest and an interested party. An event notification service typically realizes the publish/subscribe asynchronous messaging scheme.
Message Oriented Middleware
• MOM is an infrastructure that involves the passing of data between applications using a common communication channel that carries self-contained messages.
• Messages are sent and received asynchronously.
• The messaging system (integration broker) is responsible for managing the connection points between clients & for managing multiple channels of communication between the connection points.
![](https://www.chaostudy.com/wp-content/uploads/2024/03/image-20.png)
• MOM provides the following functions:
– event-driven processing, i.e., the publish/subscribe model.
– reliability and serialization of messages.
– subject-based (textual) names and attributes to abstract from physical names and addresses.
– multiple communications protocols, e.g., store & forward, request/reply, publish/subscribe.
• An integration broker is an application-to-application middleware service capable of one-to-many, many-to-one & many-to-many message distribution.
– It records & manages the contracts between publishers & subscribers of messages.
• An integration brokers provides the following functions:
– message transformation, business rules processing, routing services, naming services, adapter services, repository services, events & alerts.
Enterprise application & e-Business integration
后面还有一堆概念的东西,老师直接最后几分钟嗖嗖的就跳过去了,感觉也没啥重点。后面都是一些WWW,HTTP,这些七七八八的概念。