西维蜀黍

【Linux】ln - 硬链接与软链接

背景

在介绍链接的概念之前,我们需要先Unix/Linux文件系统和硬盘储存的基础概念。

  ...


【Distributed System】分布式系统的数据一致性(Data Consistency)

什么是数据一致性(Data Consistency)

**数据一致性(Data Consistency)**其实是数据库系统中的概念。我们可以简单地把一致性理解为正确性或者完整性。

数据库事务(Database Transaction)

我们知道,在数据库系统中通常用事务来保证数据的一致性和完整性。

数据库事务,核心是数据库ACID(原子性、一致性、隔离性和持久性)属性。即对于一个数据库事务中所有的逻辑处理操作,只有这些作用在数据库上的逻辑处理操作全部都成功时,对数据库的修改才会永久更新到数据库中。若存在任何一个操作失败,对于在此之前的所有逻辑操作都会失效(即该事务被回滚)。

  ...


【Distributed System】分布式事务 - 三阶段提交协议(Three-phase Commit Protocol)

三阶段提交协议(Three-phase Commit Protocol)

In computer networking and databases, the three-phase commit protocol (3PC) is a distributed algorithm which lets all nodes in a distributed system agree to commit a transaction. It is a more failure-resilient refinement of the two-phase commit protocol (2PC).

  ...


【Distributed System】分布式事务 - 两阶段提交协议(Two-phase Commit Protocol)

The two-phase commit (2PC) protocol should not be confused with the two-phase locking (2PL) protocol, a concurrency control protocol.

两阶段提交协议(Two-phase Commit Protocol,2PC)

In transaction processing, databases, and computer networking, the two-phase commit protocol (2PC) is a type of atomic commitment protocol (ACP). It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort (roll back) the transaction (it is a specialized type of consensus protocol). The protocol achieves its goal even in many cases of temporary system failure (involving either process, network node, communication, etc. failures), and is thus widely used.

However, it is not resilient to all possible failure configurations, and in rare cases, manual intervention is needed to remedy an outcome. To accommodate recovery from failure (automatic in most cases) the protocol’s participants use logging of the protocol’s states. Log records, which are typically slow to generate but survive failures, are used by the protocol’s recovery procedures. Many protocol variants exist that primarily differ in logging strategies and recovery mechanisms. Though usually intended to be used infrequently, recovery procedures compose a substantial portion of the protocol, due to many possible failure scenarios to be considered and supported by the protocol.

In a “normal execution” of any single distributed transaction (i.e., when no failure occurs, which is typically the most frequent situation), the protocol consists of two phases:

  1. The prepare phase (or voting phase), in which a coordinator process attempts to prepare all the transaction’s participating processes (named participants, cohorts, or workers) to take the necessary steps for either committing or aborting the transaction and to vote,
    • either “Yes”: commit (if the transaction participant’s local portion execution has ended properly),
    • or “No”: abort (if a problem has been detected with the local portion), and
  2. The commit phase, in which, based on voting of the participants, the coordinator decides whether to commit (only if all have voted “Yes”) or abort the transaction (otherwise), and notifies the result to all the participants. The participants then follow with the needed actions (commit or abort) with their local transactional resources (also called recoverable resources; e.g., database data) and their respective portions in the transaction’s other output (if applicable).
  ...


【Distributed System】分布式理论 - BASE

BASE理论

eBay 的架构师 Dan Pritchett 源于对大规模分布式系统的实践总结,在 ACM 上发表文章提出 BASE 理论,BASE 理论是对 CAP 理论的延伸,核心思想是:即使无法做到强一致性(Strong Consistency),CAP 的一致性就是强一致性),但每个应用都可以根据自身的业务特点,采用适合的方式来达到最终一致性(Eventual Consitency)。

  ...


【Distributed System】分布式理论 - CAP 理论(CAP Theorem)

背景

2000年7月,加州大学伯克利分校的Eric Brewer教授在ACM PODC会议上提出CAP猜想。2年后,麻省理工学院的Seth Gilbert和Nancy Lynch从理论上证明了CAP。之后,CAP理论正式成为分布式计算领域的公认定理。

  ...


【OOP】对象的深拷贝(Deep Copy)与浅拷贝(Shallow Copy)

数据类型

数据分为基本数据类型(String,Number,Boolean,Null,Undefined,Symbol)和对象数据类型。

  ...


【Distributed System】Data Flow - 远程过程调用(Remote Procedure Call, RPC)

什么是远程过程调用(Remote Procedure Call,RPC)

RPC 是**远程过程调用(Remote Procedure Call)**的缩写形式。

Birrell 和 Nelson 在 1984 发表于 ACM Transactions on Computer Systems 的论文《Implementing remote procedure calls》对 RPC 做了经典的诠释。RPC 是指计算机 A 上的进程,调用另外一台计算机 B 上的进程,其中 A 上的调用进程被挂起,而 B 上的被调用进程开始执行,当值返回给 A 时,A 进程继续执行。调用方可以通过使用参数将信息传送给被调用方,而后可以通过传回的结果得到信息。而这一过程,对于开发人员来说是透明的。

RPC 的主要好处有两个:

  • 程序员可以使用过程调用语义来调用远程函数并获取响应。
  • 简化了编写分布式应用程序的难度,因为 RPC 隐藏了所有的网络代码存根函数。应用程序不必担心一些细节,比如 socket、端口号以及数据的转换和解析。在 OSI 参考模型中,RPC 跨越了会话层和表示层。

RPC 使用的通信协议

RPC 可以灵活使用其所基于的协议,如果基于 HTTP,则与 Web Service 就没有什么区别了,如基于更底层的协议(如 TCP ),则会比 Web Service 相对更为高效。

  ...


【Network】GFW学习

GFW是啥

总的来说,GFW是一个分布式的入侵检测系统,并不是一个严格意义上的防火墙。不是说每个出入国境的IP包都需要先经过GFW的首可。做为一个入侵检测系统,GFW把你每一次访问facebook都看做一次入侵,然后在检测到入侵之后采取应对措施,也就是常见的连接重置。

  ...


【IoT】Why Cloud Computing is not enough for IoT

Basic Idea

In “A vision, architectural elements, and future directions”, it presents their vision of IoT and coin the term “cloud centric IoT” for a system offering data distribution and additional services in a cloud based layer.

In other words, a system uses Cloud as the proxy for all communications between things or as a data hub where IoT data are gathered and analysed.

Note that “cloud-based IoT” and “cloud centric IoT” are used interchangebly.

  ...