[雲計算技術文章之其一] 利用 IBM 雲功能構建無服務器應用程序

前言

  • 最近一兩個星期,手頭上的項目陸續交付出去了,個人的空閒時間就多了些,於是業餘活動就增多了起來,終於也有時間開始整理文檔,寫寫博客了。
  • 近期的業餘活動,除了繼續學習吳恩達老師的深度學習課程,看一看 Stephen Boyd 的著作《Convex Optimization》學習一些數學知識,還加入了騰訊雲的“雲+翻譯社”,閒下來時翻譯一些比較新的技術文章張張姿勢,身爲技術人,可不能跟不上時代啊。
  • 翻譯社第一期活動是“雲計算相關技術的前瞻性研究”,雖然跟我的學習方向不怎麼對口,但是我也領了五篇比較簡單的文章趁機漲漲姿勢。
  • 其中有三篇文章被專欄採納了,說明這幾篇翻譯還是及格的。所以我打算在這兩天整理整理,把中英對照版發在這裏。
  • 發在專欄的原文地址如下:

版權相關

翻譯人:StoneDemo,該成員來自雲+社區翻譯社
原文鏈接:Composing Serverless Apps With IBM Cloud Functions
原文作者:Niklas Heidloff


Composing Serverless Apps With IBM Cloud Functions

題目:利用 IBM 雲功能構建無服務器應用程序

At Serverlessconf, IBM announced a new key capability (as an IBM Research preview) of IBM Cloud Functions. With the new tool Composer, apps can be created that contain multiple cloud functions. These apps coordinate the invocations of actions and the data flow. Compared to the previously available action sequences, the new functionality is much more flexible.

在 IBM(國際商業機器公司) 的 Serverlessconf 網站上,官方發佈了 IBM Cloud Functions 的一項新功能(作爲 IBM Research 的一個預覽版)。我們可以使用新工具 Composer,以創建包含多個雲功能的應用程序,這些應用程序會協調動作的調用與數據流。新功能比起以前使用的動作序列相比,更爲靈活了。

Cloud functions are typically rather simple and focussed on specific tasks, which is why people often refer to cloud functions as microservices. Cloud-native applications usually have many microservices. While the implementation of the microservices is rather simple, the key challenge is the orchestration layer above the microservices. That’s why frameworks like Kubernetes, with additions like Istio, have become very popular. With the new Composer tool, developers can now build apps that leverage multiple cloud functions and that require more complex, coordinated flows for end-to-end solutions.

雲功能一般來說是非常簡單,且專注於特定任務的,這也是人們通常將雲功能稱爲微服務的原因。雲本地應用程序通常包含了許多的微服務。微服務的實現非常簡單,其技術難點在於微服務之上的流程編排層。這就是像 Kubernetes 這樣的框架,與 Istio 這樣的附加組件已變得非常流行的原因。開發人員現在可以使用新工具 Composer 來構建能夠利用多種雲功能的應用程序,但這需要更復雜、協調一致的流程來實現端到端的解決方案。

Composer is an IBM Cloud Functions programming model for composing individual functions into larger applications. Compositions, informally named apps, run in the cloud using automatically managed compute and memory resources. Composer is an extension of the function-as-a-service computing model, and enables stateful computation, control flow, and rich patterns of data flow. Composer has two parts. The first is a library for describing compositions, programmatically. The library is currently available in Node.js. The second is a runtime that executes the composition.

Composer 是 IBM Cloud Functions 編程模型,該模型用於將各個獨立功能組合成更大的應用程序。組合模式、非正式命名程序,都是使用自動管理的計算與內存資源運行在雲服務器中。Composer 是對功能服務(FaaS)計算模型的一個擴展,它支持狀態計算、控制流和豐富的數據流模式。Composer 由兩部分組成:第一個,是以編程方式描述組合模式的庫,該庫目前在 Node.js 中是可用的。第二個則是執行組合模式的運行時環境。

Let’s take a look at a simple example. With the new Composer functionality, different functions can be invoked depending on the result of a previous function. The screenshot shows the new tool ‘fsh’ (functional programming shell), which displays the flow graphically.

現在我們來看一個簡單的例子。使用新的 Composer 功能,我們可以根據前一個功能的返回結果來決定調用特定的下一功能。下面的屏幕截圖展示了新工具“fsh”(函數式編程殼),它以圖形的方式來顯示流程。

這裏寫圖片描述

The apps (compositions) can be defined via JSON, which is executed by a runtime component. In addition to ‘if’, many other composition methods are supported.

應用程序(組合模式)可以通過由運行時環境組件所執行的 JSON 來定義。除了 “if” 方式之外,目前還支持許多其他構圖方法

這裏寫圖片描述

What I really like is the second approach to defining apps, which I think is more natural for developers. While you can define apps as JSON configurations, you can also write Node.js code that uses the Composer SDK, and you can use constructs as variables, try/catch statements, loops, data forwarding, and much more.

我所喜歡的是第二種定義應用程序的方法,因爲我認爲這一方法對於開發者而言更爲自然。您可以將應用程序定義爲 JSON 配置,也可以編寫使用 Composer SDK 的 Node.js 代碼,並使用構造變量,try / catch語句,循環,數據轉發等等。

這裏寫圖片描述

The Node.js code is compiled into JSON, which is executed by the runtime. In order to handle the state of the apps, developers need to provision Redis datastores (see the documentation for details). The managed runtime, together with the datastore, allows hosting and running serverless apps.

To find out more, check out the quick start guide.

Node.js 代碼會被編譯成 JSON,並由運行時環境來執行。開發人員需要配置 Redis 數據存儲以處理應用程序的狀態(詳情參閱:文檔)。運行時環境與數據存儲允許託管和運行無服務器式應用程序。

若想要了解更多信息,請查看快速入門指南

發佈了28 篇原創文章 · 獲贊 82 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章