無服務器架構(Serverless Architecture)
•無服務器架構是指一種軟體設計模式,其中應用程序由第三方服務託管
•消除了管理服務器軟件和硬件的需要消費者 這些由雲供應商管理
•無服務器應用程序是事件驅動的基於雲的系統,它是結合第三方服務和雲託管功能來執行你的業務邏輯
•無服務器也稱為構建應用程序的功能即服務樣式
Traditional Hosting vs. Serverless Hosting
Azure Services based on Serverless Architecture
Functional Programming
•作為工作單元的功能
•函數有輸入和輸出
•函數應該“做一件事”。
•Functions should be idempotent.。
(也就是說同樣的請求即使不小心送了兩次,也不用擔心對server端造成不同的影響。)
Ref:https://www.rfc-editor.org/rfc/rfc7231#section-4.2.2
A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request. Of the request methods defined by this specification, PUT, DELETE, and safe request methods are idempotent.
•Functions should finish as quickly as possible.
Azure Functions
•基於Serverless架構和Web Jobs的演進
•可支援使用 C#、Node、Java、Python、Php 等程式語言開發函數(透過類似nuget,npm來安裝相應API套件)
•跨服務輕鬆安排事件驅動的任務
•將Functions公開為 HTTP API 端點
•輕鬆與邏輯應用集成
•Support Automatic, dynamic scaling
Azure Functions Architecture
實作種類又細分為
Azure Functions : Scheduled data processing
Azure Functions : Real Time Event Processing
Azure Functions : Serverless Web Application
Azure Functions : Serverless Mobile backend
基於Azure Function Plans分類則可分類如下
App Service Plan(應用服務計劃)
•使用現有的應用服務計劃
•可預測的每月費用
Consumption Plan(消費計劃)
•為你使用的東西付費
•根據每秒資源消耗和執行次數計費
•Includes a monthly free grant of 1 million requests and 4,00,000 GB s of resource
consumption in pay as you go pricing across all function apps
Premium Plan(高級計劃)
•提供增強的性能
•Billed on a per second basis based on the number of vCPU s and GB s your
Premium Functions consume