Welcome to the Real World

Gregor Hohpe

EnginEERS liKE pRECiSion, especially software engineers who live in the realm of ones and zeros. They are used to working with binary decisions, one or zero, true or false, yes or no. Everything is clear and consistent, guaranteed by foreign key constraints, atomic transactions, and checksums.

Unfortunately, the real world is not quite that binary. Customers place orders, only to cancel them a moment later. Checks bounce, letters are lost, payments delayed, and promises broken. Data entry errors are bound to happen every so often. Users prefer “shallow” user interfaces, which give them access to many functions at once without being boxed into a lengthy, one-dimensional “pro- cess,” which is easier to program and seems more “logical” to many developers. Instead of the call stack controlling the program flow, the user is in charge.

Worse yet, widely distributed systems introduce a whole new set of inconsis- tencies into the game. Services may not be reachable, change without prior notice, or do not provide transactional guarantees. When you run applica- tions on thousands of machine, failure is no longer a question of “if,” but of “when.” These systems are loosely coupled, asynchronous, concurrent, and do not adhere to traditional transaction semantics. You should have taken the blue pill!

As computer scientists’ brave new world is crumbling, what are we to do?

As is so often the case, awareness is a first important step toward a solution.



Say goodbye to the good old predictive call-stack architecture, where you get to define what happens when and in what order. Instead, be ready to respond to events at any time in any order, regaining your context as needed. Make asynchronous requests concurrently instead of calling methods one by one. Avoid complete chaos by modeling your application using event-driven pro- cess chains or state models. Reconcile errors through compensation, retry, or tentative operations.

Sounds scary and more than you bargained for? Luckily, the real world has to deal with the same issues for a long time: delayed letters, broken prom- ises, messages crossing in transit, payments posted to the wrong account—the examples are countless. Accordingly, people had to resend letters, write off bad orders, or tell you to ignore the payment reminder in case you already sent a payment. So don’t just blame the real world for your headaches, but also use it as a place to look for solutions. After all, Starbucks does not two-phase com- mit, either.1 Welcome to the real world.

Gregor Hohpe is a software architect with Google, Inc. Gregor is a widely rec- ognized thought leader on asynchronous messaging architectures and service- oriented architectures. He coauthored the seminal book Enterprise Integration Patterns (Addison-Wesley Professional) and speaks regularly at technical conferences around the world.

随机推荐

  1. bzoj3555 [Ctsc2014]企鹅QQ——字符串哈希

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3555 很久以前就讲过哈希,但一直没写过题,所以这是哈希第一题! 哈希就是把一个字符串映射成一 ...

  2. 协同过滤算法中皮尔逊相关系数的计算 C++

    template <class T1, class T2>double Pearson(std::vector<T1> &inst1, std::vector<T ...

  3. php的get_object_vars函数

    我在看ecshop源码的时候,发现了一个非常有趣的函数,在此记下:get_object_vars() 从字面我们可以猜到,这个函数是针对类的一个方法:语法:array  get_object_vars ...

  4. BZOJ 4563 错排+高精度

    思路: 把障碍移到对角线 就发现 这是个错位排列问题 用错排公式即可解 s[i]=(s[i-1]+s[i-2])*i //By SiriusRen #include <cstdio> #i ...

  5. BZOJ 2431 逆序对数列 DP

    2431: [HAOI2009]逆序对数列 Time Limit: 5 Sec Memory Limit: 128 MB Description 对于一个数列{ai},如果有i< j且ai> ...

  6. Oracle 生成数据字典

    SELECT ROWNUM 序号,A.COLUMN_NAME AS "字段名称",B.comments AS "字段描述", A.DATA_TYPE as 字段 ...

  7. Xcode控制台输出中文

    创建一个.m文件,然后将一下代码加入.m文件中即可实现控制台输出中文,具体代码如下: #ifndef Release @implementation NSSet(Log) - (NSString *) ...

  8. poj3009 Curling 2.0 深搜

    PS:以前看到题目这么长就没写下去了.今天做了半天,没做出来.准备看题解,打开了网站都忍住了,最后还是靠自己做出来的.算是一点进步吧. 分析: 题目的意思没明白或者理解有偏差都没办法做题.看样例3和样 ...

  9. page事件

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  10. mysql自动添加时间的方法

    时间添加方法,可以在编辑数据时方便时间选择输入: 将时间列DataType设为timestamp,设定其默认值为CURRENT_TIMESTAMP. 这样每次插入一条新纪录,数据库会自动在时间段存储当 ...