2012/06/20

Beautiful Architecture

Common among the notions of architecture is the idea of structures, each defined by components of various sorts and their relations: how they fit together, invoke each other, communicate, synchronize, and otherwise interact.


Table 1-1. Structure summary
Structure Components Relations Concerns
Information Hiding Information Hiding Modules Is a part of

Is contained in
Changeability

Modularity

Buildability
Uses Programs Uses Producibility

Ecosystem
Process Processes (tasks, threads) Gives work to

Gets resources from

Shares resources with

Contained in

...
Performance

Changeability

Capacity
Data Access Programs and Segments Has access to Security

Ecosystem


决定architecture的第一步是和stakeholders to understand and prioritize quality concerns and constraints,而不是通过functional requirements来决定architecture,因为满足functional requirements的architecture很多,选择其中一个的决定取决于quality concerns,并不是所有的可能都能达到要求。比如呈现网页的architecture很多,CGI,静态网页,ASP,JSP,Python。

Fred Brooks said that conceptual integrity is the most important attribute of an architecture: "It is better to have a system...reflect one set of design ideas, than to have one that contains many good but independent and uncoordinated ideas" (1995).

The first class of evaluation methods determines properties of the architecture, often by modeling or simulation of one or more aspects of the system.

A consistent architecture does not offer two (or more) ways to do the same thing, forcing the user to waste time choosing.

We would look for architectures with a well-defined Uses Structure that would support incremental construction, so that at each iteration of construction we would have a useful, testable system. We would also look for architectures that have well-defined module interfaces and that are inherently testable, so that the construction progress is transparent and visible.

2.2. Design Town

第一步,conceptional design,例如模块的划分,结构分层,业务流程模型,辅助库的选择。

3.2 Project Darkstar

Massively Multiplayer Online games (MMOs),需要结构能scaling;Multi-cores chip evolution,需要concurrent。但是

This context gave us our first goal for the architecture. The requirements for scaling dictated that the system be distributed and concurrent, but we needed to present a much simpler programming model to the game developer. The simple statement of the goal is that the game developer should see the system as a single machine running a single thread, and all of the mechanisms that would allow deployment on multiple threads and multiple machines should be taken care of by the Project Darkstar infrastructure.

The general programming model that Project Darkstar requires is a reactive one, in which the server side of the game is written as a listener for events generated by the clients. When an event is detected, the game server should generate a task, which is a short-lived sequence of computations that includes manipulation of information in the virtual world and communication with the client that generated the original event and possibly with other clients. Tasks can also be generated by the game server itself, either as a response to some internal change or on a periodic, timed basis. In this way, the game server can generate characters in the game or world that aren't controlled by some outside player.

Darkstar在server端实现了一些独立的services,类似典型的操作系统,给server端的游戏提供access persistent storage, schedule and run tasks, and perform communication服务。服务的实现被隐藏在服务的接口后面,允许其实现的变化。

game的特点,不会有对数据的复杂query,每个task大概会query十几个对象。被query的对象一半的机会会被task修改。

task被包在一个transaction里面。如果两个task要修改一份数据(通过data service提供的接口),data service会做出仲裁,访问失败的task会被reschedule。

Session Service管理客户端的login,认证,建立session,一旦session建立,客户端发向server的message会被Session Service解析,并且决定产生什么task。Session Service确保同一个客户端发的message被顺序处理,这样Task Service就不用关心task的顺序问题,
Session掩盖了底部的通信机制,所以Session的实际连接可以被重定向,移动到不同的server。

有点高级了,所有的tasks都被编译成java vm的bytecodes,可以在任何满足条件的环境里运行。

tasks都是被序列化的,server crash过程中丢失的task会被恢复出来,在别的server上reschedule,crash问题就转化成了延迟。

All data that lasts longer than a particular task be stored persistently.这种设计的读写延迟可以用更底层的cache技术优化。

Service结构的设计使得server端可以对通信监控,可以自由的把交互频繁的客户端的session移到同一个server,而得到更好的运行效率。

4. Making Memories

As we look at each of these facets, keep in mind that they are different ways of looking at the overall system. For instance, we used a modular architecture to support different deployment scenarios. At the same time, each module is built in a layered architecture. These are orthogonal but intersecting concerns. Each set of modules follows the same layering, and each layer is found across all the modules.

5. Resource-Oriented Architectures

What the business really wants are easier ways to manage the data they have collected, build upon it, and reuse it to support their customers and core functions.





No comments:

Post a Comment

Print This Post