Monolithic Architecture

This post is part ofThe Software Architecture Chronicles, a?series of posts about Software Architecture. In them, I write about what I’ve learned on Software Architecture, how I think of it, and how I use that knowledge. The contents of this post might make more sense if you read the previous posts in this series.

In the beginning, there was the Monolith…?

Building a monolith has always been the default Architectural Style. I mean, in the very beginning we had one file per application, then we started having applications with several files, and only since the 1990s we started to see applications composed of other applications (although the first experimentations were during the 1980s).

The monolith itself evolved. When applications started to be built using multiple files, there wasn’t?much reasoning about them, nor there was a big need for that reasoning because the applications were relatively simple. As the applications got bigger and more complex, there was a need for some reasoning behind what files to create and how to relate them.

Modular Software Development

Modular Programming was the solution proposed in the late 1960s and during the?1970s. It was?an evolution from classes to a more coarse-grained explicit definition of code units. Programming languages implemented modularity with different grades of explicitness.

For example, JAVA has class level visibility of?default?and?public, where?default?level means that a class is only visible in its package (module), and?public?means that the class is visible in and outside of its package (module). This allows us to define what classes should be used by the clients of a package.

Componentized Software Development

Another style of modularity are the Components. As explained in?one of my previous posts, Components are modules created with a domain concept in mind. They are ideally standalone “applications” that can be used to create composite applications. A recurrent example of this style if the pipes and filters architecture, extensively used in Unix systems and that allows us to do something like “ps -ef | grep php“. Another example is the usage of microservices?as components of composite applications, like Netflix.

This style of code organisation also has been around for a long time, going back to the late 1960s, just like modular software development.

The modern monolith

Nowadays, having a monolithic Architectural Style simply means that all of the application?code is deployed and?run as a single process on a single node. We assume, it is using modules and components, although it is in fact often not the case.

It’s important to understand why the key words here are “deployed” and “node”. Regarding the first one,?deployed, it means that it doesn’t matter where the code is physically stored if it is organised in one or several repositories, but how it is organised at runtime. Regarding the second keyword,?node, it means that it is still a monolith if we deploy the application to several servers, as in a horizontal scaling context.

In a single node server,?all of the modules in a monolith are assembled to the same memory image, which is run as a single process on a single node. Communication is done through standard procedure calls through the same stack and heap. It’s the single memory image makes the application monolithic. If you are running modules in different processes, you’re doing IPC. Because modules fall into different process boundaries, you’ll start facing distributed computing challenges. That’s getting into?microservice?territory.?(Thank you for your?feedback,_dban_)

This style, although with very bad reputation, can work very well even for large applications. It only stops being?good enough when we need:

Independent scalability?of different domain components;

Different?components or modules to be written in?different programming languages;

Independent deployability, maybe because we have a release rate higher than the deployment pipeline can handle for one code base, causing the deployment of a release to be slow because it needs to wait for the deployment of other releases, or even causing the deployment queue to grow faster than it is consumed.

At that point, we need to segregate our monolith into different applications, in an SOA Architectural Style (more on that in a followup post).

Anti-pattern: Big Ball of Mud /?Spaghetti Architecture

The “big ball of mud”, AKA Spaghetti Architecture, is the anti-pattern for this style, where the packages structure and relations are not explicit, structural cohesion and encapsulation does not exist or is minimal, dependencies follow no rules and it is very difficult to reason about subsystems, to make changes and to refactor. The system is?opaque,?viscous,?fragile?and?rigid: A?Big Ball of Mud!

Sources

1997 – Brian Foote, Joseph Yoder?–?Big Ball of Mud

2012 – Len Bass, Paul Clements, Rick Kazman –Software Architecture in Practice

2017 – Herberto Gra?a –?Microservices architecture: What the gurus say about it

2017 – Herberto Graca –Software Architecture Premises

2017* – Wikipedia –Modular programming

2017* – Wikipedia –Component-based software engineering

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末卡骂,一起剝皮案震驚了整個(gè)濱河市恬涧,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌泵额,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,104評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異抑钟,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)野哭,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,816評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門在塔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人拨黔,你說(shuō)我怎么就攤上這事蛔溃。” “怎么了?”我有些...
    開封第一講書人閱讀 168,697評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵贺待,是天一觀的道長(zhǎng)徽曲。 經(jīng)常有香客問(wèn)我,道長(zhǎng)麸塞,這世上最難降的妖魔是什么疟位? 我笑而不...
    開封第一講書人閱讀 59,836評(píng)論 1 298
  • 正文 為了忘掉前任,我火速辦了婚禮喘垂,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘绍撞。我一直安慰自己正勒,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,851評(píng)論 6 397
  • 文/花漫 我一把揭開白布傻铣。 她就那樣靜靜地躺著章贞,像睡著了一般。 火紅的嫁衣襯著肌膚如雪非洲。 梳的紋絲不亂的頭發(fā)上鸭限,一...
    開封第一講書人閱讀 52,441評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音两踏,去河邊找鬼败京。 笑死,一個(gè)胖子當(dāng)著我的面吹牛梦染,可吹牛的內(nèi)容都是我干的赡麦。 我是一名探鬼主播,決...
    沈念sama閱讀 40,992評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼帕识,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼泛粹!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起肮疗,我...
    開封第一講書人閱讀 39,899評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤晶姊,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后伪货,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體们衙,經(jīng)...
    沈念sama閱讀 46,457評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,529評(píng)論 3 341
  • 正文 我和宋清朗相戀三年超歌,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了砍艾。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,664評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡巍举,死狀恐怖脆荷,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤蜓谋,帶...
    沈念sama閱讀 36,346評(píng)論 5 350
  • 正文 年R本政府宣布梦皮,位于F島的核電站,受9級(jí)特大地震影響桃焕,放射性物質(zhì)發(fā)生泄漏剑肯。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,025評(píng)論 3 334
  • 文/蒙蒙 一观堂、第九天 我趴在偏房一處隱蔽的房頂上張望让网。 院中可真熱鬧,春花似錦师痕、人聲如沸溃睹。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,511評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)因篇。三九已至,卻和暖如春笔横,著一層夾襖步出監(jiān)牢的瞬間竞滓,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,611評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工吹缔, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留商佑,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,081評(píng)論 3 377
  • 正文 我出身青樓厢塘,卻偏偏與公主長(zhǎng)得像莉御,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子俗冻,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,675評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容