All Projects → cloudframeworks-faas-serverless → user-guide-faas-serverless

cloudframeworks-faas-serverless / user-guide-faas-serverless

Licence: Apache-2.0 License
[Cloudframeworks]Function as a Service & Serverless Architectures / [云框架]FaaS & Serverless架构

Projects that are alternatives of or similar to user-guide-faas-serverless

honeypie
A FaaS for converting your Google Forms into an API.
Stars: ✭ 17 (-22.73%)
Mutual labels:  faas
cli
Autocode CLI and standard library tooling
Stars: ✭ 3,791 (+17131.82%)
Mutual labels:  faas
tencent-tensorflow-scf
A template project for serverless functions for Tensorflow inference on Tencent Cloud.
Stars: ✭ 38 (+72.73%)
Mutual labels:  faas
aws-lambda-r
Using R on AWS Lambda
Stars: ✭ 51 (+131.82%)
Mutual labels:  faas
hex-example
Little API to demonstrate various microservice design principles and technologies
Stars: ✭ 131 (+495.45%)
Mutual labels:  faas
go-appsync-graphql-cloudformation
AWS AppSync GraphQL API Proxy with Lambda, CloudFormation, and SAM
Stars: ✭ 28 (+27.27%)
Mutual labels:  faas
serverless-scaleway-functions
Plugin for Serverless Framework to allow users to deploy their serverless applications on Scaleway Functions
Stars: ✭ 58 (+163.64%)
Mutual labels:  faas
microless
Using docker and nodejs to build Microservice
Stars: ✭ 16 (-27.27%)
Mutual labels:  faas
faas-fargate
OpenFaaS on AWS Fargate. Open source Functions as a Service without any infrastructure to manage
Stars: ✭ 50 (+127.27%)
Mutual labels:  faas
openfaas-rstats-templates
OpenFaaS templates for R
Stars: ✭ 17 (-22.73%)
Mutual labels:  faas
openwhisk-runtime-go
Apache OpenWhisk Runtime Go supports Apache OpenWhisk functions written in Go
Stars: ✭ 31 (+40.91%)
Mutual labels:  faas
lambda-memory-performance-benchmark
Performance and cost benchmark tool for AWS Lambda on memory sizes 📈⏱
Stars: ✭ 60 (+172.73%)
Mutual labels:  faas
fn-helm
Helm Chart for Fn
Stars: ✭ 51 (+131.82%)
Mutual labels:  faas
xkcd-excuse-generator
Serverless image generator that uses XKCD comic as basis for _all_ excuses!
Stars: ✭ 63 (+186.36%)
Mutual labels:  faas
kubeless
Kubernetes Native Serverless Framework
Stars: ✭ 6,848 (+31027.27%)
Mutual labels:  faas
serverless
BlueNimble is a Hybrid Serverless Platform focusing on developer productivity and application portability. Create and run scalable APIs and applications without coding or by coding less. Focus on application business logic without any knowledge of the underlying microservices architecture.
Stars: ✭ 30 (+36.36%)
Mutual labels:  faas
swarm-gcp-faas
Setup OpenFaaS on Google Cloud with Terraform, Docker Swarm and Weave
Stars: ✭ 15 (-31.82%)
Mutual labels:  faas
reactr
Function scheduler for Go & WebAssembly
Stars: ✭ 264 (+1100%)
Mutual labels:  faas
aws-sdk-extra
The AWS SDK + a handful of extra convenience methods.
Stars: ✭ 18 (-18.18%)
Mutual labels:  faas
openwhisk-runtime-python
Apache OpenWhisk Runtime Python supports Apache OpenWhisk functions written in Python
Stars: ✭ 39 (+77.27%)
Mutual labels:  faas

[云框架]FaaS Serverless架构

FaaS(Function as a Service)/Serverless概念在最初并不为大众所接受,但随着微服务架构及事件驱动架构的发展成熟,越来越多人认识到了其中价值。(Serverless架构综述

简单来说,FaaS/Serverless是一种新的计算范例,为开发者和运营商提供简单、高效、可扩展的计算方法,我们可以把它看作是比微服务更细粒度的架构模式。FaaS/Serverless并不意味着没有服务器,而是通过将复杂的服务器架构透明化,使开发者专注于业务/任务本身,强调了一种减少计算资源关注、工作粒度从服务器切换到“任务”的思想。(FaaS、PaaS和无服务器体系结构的优势

对于开发者来说,FaaS/Serverless意味着:

  • 无需管理服务器,仅需关注业务代码,其他工作将由平台完成

  • 代码微小化,只完成一个功能,维护升级非常简单

  • 需要时执行计算任务,无需支付闲时费用(真正的按需计算和付费)

对于平台运营者来说,FaaS/Serverless意味着:

  • 资源利用率极高,只在实际计算时消耗资源

  • 一个适用于任何语言、任何技术设计的方法的统一运行平台

本篇云框架将以一个自建FaaS平台 http://www.faas.pro 及两个FaaS方法(function)实例ETCD_v3Twitter Function Image为例介绍FaaS/Serverless及其最佳实践。

适用于以下场景:

  • 低频请求场景

  • 流量突发场景

内容概览

在线演示

http://www.faas.pro

快速部署

平台部署

  1. 安装Docker及Docker Compose

  2. 准备域名(这里使用faas.org域名进行部署安装,若你有自己的域名,可使用自己的域名)

  • 增加本地域名解析(可能需要使用sudo su命令切换到root账户)
sudo echo "机器IP www.faas.org" >> /etc/hosts
sudo echo "机器IP api.faas.org" >> /etc/hosts
sudo echo "机器IP hub.faas.org" >> /etc/hosts
sudo wget -P /etc/ssl/faas.org/ fs.faas.pro/faas.org.key
sudo wget -P /etc/ssl/faas.org/ fs.faas.pro/faas.org.crt
  1. 平台安装

  2. 安装Fn客户端(Fn - CLI tool

    curl http://fs.faas.pro/fn | sh
    export API_URL=http://api.faas.org
    fn --help
    
  3. 访问平台

方法实例

在进行操作实例前需注意:

  • 确保上文平台及Fn客户端已完整部署

  • 确认配置环境变量API_URL=http://api.faas.org

ETCD v3 FaaS方法实例

ETCD_v3介绍

查看方法源码

  1. 部署一个ETCD_v3应用 ,若已部署忽略本步骤。 (部署方式)

  2. 创建应用(etcd_v3 server地址替换***

fn apps create --config ETCD_SERVER=*** etcd_v3
  1. 创建路由
fn routes create etcd_v3 /command -i hub.faas.pro/etcd_v3:0.0.1
  1. 运行方法
  • PUT
echo '{"method":"put","key":"hello","value":"world"}' | fn call etcd_v3  /command
  • GET
echo '{"method":"get","key":"hello"}' | fn call etcd_v3 /command

Twitter Function Image方法实例

Twitter Function Image可用于查看推文(需要科学上网

查看方法源码

  1. 配置Twitter Appconfigure Customer Access and Access Token

  2. 创建应用(根据你的twitter账号信息更改***)

fn apps create --config ACCESS_SECRET=*** --config ACCESS_TOKEN=*** --config CUSTOMER_KEY=*** --config CUSTOMER_SECRET=*** twitter
  1. 创建路由
fn routes create twitter /tweets -i hub.faas.pro/func-twitter:0.0.1

  1. 运行方法,可以使用任何人的账号名替换***(username值)
echo '{"username":"***"}' | fn call twitter /tweets

框架说明-平台

平台架构图如下所示:

  • Traefik:了解学习现代化反向代理/负载均衡

  • FunctionAPI:提供一个无状态的API服务。提供FaaS方法创建,配置,运行等API

  • Mysql:存储FaaS方法元数据

  • Redis:消息队列,每次方法调用API产生的任务送往消息队列,调度与执行器从消息队列获取任务并执行

  • Fn:命令行客户端,使你本地开发、本地部署

  • Hub:存储你的方法镜像,使用docker官方镜像仓库服务。项目地址:https://github.com/docker/distribution

开发你的FaaS方法

如果想要自己开发FaaS方法,可参考ETCD_v3Twitter Function Image这两个例子。

需要注意的是,与普通应用相比,FaaS方法有以下特点/不同:

  • FaaS方法可使用任何语言进行开发
  • FaaS方法具有一定的运行时间,即完成计算后退出
  • FaaS方法从标准输入或环境变量获取输入数据,以标准输出输出计算结果
  • FaaS方法需要以dockerfile进行镜像打包

步骤:

  1. 使用fn命令构建你的代码:
# 创建func.yaml文件 - 用Docker Hub username替换$USERNAME
fn init $USERNAME/hello

# 创建function
fn build

# 测试 - 通过管道传入数据, 例如:`cat hello.payload.json | fn run`
fn run

# 完成后构建并将其push至Docker Hub
fn build && fn push

# 创建一个app - 每个app仅执行一次
fn apps create myapp

# 为function创建一个route
fn routes create myapp /hello
  1. 使用lambda函数(确保你的node.js主处理函数文件名为:func.js)
fn init --runtime lambda-node hub.faas.org/lambda-node

生产环境

TODO

常见问题

TODO

更新计划

TODO

点击查看历史更新

社群贡献


云框架系列主题,遵循APACHE LICENSE 2.0协议发布。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].