来源: https://thenewstack.io/openfaas-put-serverless-function-container/?utm_source=tuicool&utm_medium=referral

Why limit serverless functions to whatever programming languages that are supported by the provider?

OpenFaaS is a new open source serverless software program can run any CLI-driven binary program embedded in a Docker container. “Any command line interface that runs on Linux we can package it,” boasted Alex Ellis, who created OpenFaaS and by day works as a software engineer for ADP.

In effect, any program that can be run from the command line can be containerized and served up as a function through OpenFaaS. Even complex multimedia Linux apps such as FFmpeg or ImageMagick can be packaged as a function in about five lines as a Docker file.

The first deployments of serverless, such as AWS Lambda, were very much proprietary services, meaning that the end-user has no control over the back-end platform running the code (indeed, this is where the term “serverless” comes from). Commercial serverless services are also typically restricted by the languages they specifically support. In Lambda’s case, this means Node.js (JavaScript), Python, Java, and C# in Lambda’s case.

OpenFaas eliminates both of these issues. “OpenFaaS is serverless on your terms,” Ellis said, speaking with us at the Linux Foundation’s Open Source Summit last month.

OpenFaaS began as a side hack for a project that Ellis was working on to make use of his Amazon Alexa voice service. He had a Raspberry Pi running multi-color lights on a Christmas tree, which he wanted to control by way of Alexa.

Ellis found the prep work to be tedious to run his code on Lambda though — every change required repackaging the code, along with a Node.js instance, into a zip file that would then have to be uploaded to Amazon.

Instead, Ellispackaged his code in a container that would be managed by Docker Swarm and switched out the endpoint from Lambda to an HTTP call.

Ellis’ work drew lots of attention, both from his write-ups in Hacker News as well as from Docker, which gave him a spot to show his work at last year’s conference as “Cool Hack.”

OpenFaaS (originally called Docker FaaS) follows the Unix model of pipelines, wherein multiple components can be strung together through standard in (stdin) and standard out (stdout) streams.

The API gateway, written in Go, acts like a reverse proxy, from which users can call functions, with the gateway keeping track of the routing. The API reads the request body and headers of a request forwarding it to the appropriate container and piping the results back to the user.

 
 

In effect, Ellis had replaced Lambda back-end with some crafty staging through the Docker Swarmorchestration tool. Kubernetes can also be used, and the codebase is simple enough that others can easily add their own orchestration engine, such as someone did for Rancher CattleEllis said.

The container encapsulating the function/program listens on port 8080 for requests. This is done through a copy of Ellis’ Function Watchdog component placed within the container, which shuttles the HTTP requests between the function and the user. When a new request is in, the Watchdog forks the process and ships the request data in.

The Function Watchdog acts a bit like the old Common Gateway Interface (CGI), oft used in the early days of the Web. In fact, to speed performance, Ellis actually cribbed some techniques from the Fast CGI, a performance-minded extension of CGI.

Worried about the overhead with firing up a new JVM for every Java application, Ellis designed the Watchdog to fork several identical processes, rather than just one, in case additional instances would be needed. “As requests come in, they would always use one of the pooled processes,” thus slimming the startup time, Ellis said.  Instead of the weird, now all-but-forgotten, binary protocol Fast CGI employed, Ellis applied the lesson to standard HTTP.

For autoscaling, he used Docker Swarm replicas to create additional instances, which can be triggered into existence via a JSON alert from the Prometheusmonitoring tool. Miniohandles the scaling out of storage, which provides an AWS s3-compatible API.

 
 
 
 
 

转 OpenFaaS 介绍的更多相关文章

  1. openfaas 架构介绍

     此为官方介绍   Overview of OpenFaaS Function Watchdog You can make any Docker image into a serverless fun ...

  2. openfaas 了解

    1. 官方介绍 OpenFaaS (Functions as a Service) is a framework for building serverless functions with Dock ...

  3. CSS3 background-image背景图片相关介绍

    这里将会介绍如何通过background-image设置背景图片,以及背景图片的平铺.拉伸.偏移.设置大小等操作. 1. 背景图片样式分类 CSS中设置元素背景图片及其背景图片样式的属性主要以下几个: ...

  4. MySQL高级知识- MySQL的架构介绍

    [TOC] 1.MySQL 简介 概述 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL是一种关联数据库管理系统,将数据保存在不同的表中,而 ...

  5. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  6. Linux下服务器端开发流程及相关工具介绍(C++)

    去年刚毕业来公司后,做为新人,发现很多东西都没有文档,各种工具和地址都是口口相传的,而且很多时候都是不知道有哪些工具可以使用,所以当时就想把自己接触到的这些东西记录下来,为后来者提供参考,相当于一个路 ...

  7. JavaScript var关键字、变量的状态、异常处理、命名规范等介绍

    本篇主要介绍var关键字.变量的undefined和null状态.异常处理.命名规范. 目录 1. var 关键字:介绍var关键字的使用. 2. 变量的状态:介绍变量的未定义.已定义未赋值.已定义已 ...

  8. HTML DOM 介绍

    本篇主要介绍DOM内容.DOM 节点.节点属性以及获取HTML元素的方法. 目录 1. 介绍 DOM:介绍DOM,以及对DOM分类和功能的说明. 2. DOM 节点:介绍DOM节点分类和节点层次. 3 ...

  9. HTML 事件(一) 事件的介绍

    本篇主要介绍HTML中的事件知识:事件相关术语.DOM事件规范.事件对象. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三 ...

随机推荐

  1. MySQL数据库的主从同步复制配置

    一.主从同步机制原理 MYSQL主从同步是在MySQL主从复制(Master-Slave Replication)基础上实现的,通过设置在Master MySQL上的binlog(使其处于打开状态), ...

  2. Could not find com.android.support:appcompat-v7:23.1.1

    在刚接触Android Studio的时候,这玩意整起来确实费劲,现在接触多了,感觉还好,毕竟还有一段提升的空间,以后的必然趋势,所以还是潜心下来好好搞搞. 废话少说,切入正题. 如图所示的error ...

  3. MarkDown初学者使用指南

    换MarkDown编辑器了,突然发现自己不会,尴尬!所以顺便总结下Markdown的常用语法 标题 一级标题(格式:#+XXXXX) 二级标题(格式:##+XXXXXX) 三级标题(格式:###+XX ...

  4. elasticsearch 拼音搜索

    现在很多公司都开始使用es来做搜索,我们公司目前也有好几个业务部门在用,我主要做商户搜索,为业务部门提供基础支持.上周把呼叫中心的搜索重新整理了下,在新增几个字段后,全量同步发现通过拼音首字母搜索无法 ...

  5. Java视频教程等百度云资源分享——更新ing

    韩顺平javase(87讲)密码:hsp789 链接:https://pan.baidu.com/s/1eNCyvFcVHsd7P4gdvrFqtw密码:el1y 韩顺平javaee(66讲)密码:h ...

  6. PAT1076. Forwards on Weibo (30)

    使用DFS出现超时,改成bfs DFS #include <iostream> #include <vector> #include <set> using nam ...

  7. MYSQL 多实例运行

    1.创建数据文件 mkdir /var/lib/mysql_3307 mysql_install_db --datadir=/var/lib/mysql_3307 --user=mysql 2.给数据 ...

  8. Javascript -- 级联菜单, javascript解析xml文件

    1. cities.xml 保存省份和城市 <?xml version="1.0" encoding="GB2312"?> <china> ...

  9. SVM-支持向量机原理详解与实践

    前言 去年由于工作项目的需要实际运用到了SVM和ANN算法,也就是支持向量机和人工神经网络算法,主要是实现项目中的实时采集图片(工业高速摄像头采集)的图像识别的这一部分功能,虽然几经波折,但是还好最终 ...

  10. Origin软件作图留白过多问题解决

    解决空白过大方法:1.Tools——>Options2.Page——>Copy page setting——>Margin默认是Page,下拉菜单选Border,Clip Borde ...