热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

转OpenFaaS介绍

来源:https:thenewstack.ioopenfaas-put-serverless-function-container?utm_sourcetuicool

来源: 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, Ellis packaged 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 Swarm orchestration 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 Cattle, Ellis 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. Minio handles the scaling out of storage, which provides an AWS s3-compatible API.




推荐阅读
  • 在Cisco IOS XR系统中,存在提供服务的服务器和使用这些服务的客户端。本文深入探讨了进程与线程状态转换机制,分析了其在系统性能优化中的关键作用,并提出了改进措施,以提高系统的响应速度和资源利用率。通过详细研究状态转换的各个环节,本文为开发人员和系统管理员提供了实用的指导,旨在提升整体系统效率和稳定性。 ... [详细]
  • 优化后的标题:深入探讨网关安全:将微服务升级为OAuth2资源服务器的最佳实践
    本文深入探讨了如何将微服务升级为OAuth2资源服务器,以订单服务为例,详细介绍了在POM文件中添加 `spring-cloud-starter-oauth2` 依赖,并配置Spring Security以实现对微服务的保护。通过这一过程,不仅增强了系统的安全性,还提高了资源访问的可控性和灵活性。文章还讨论了最佳实践,包括如何配置OAuth2客户端和资源服务器,以及如何处理常见的安全问题和错误。 ... [详细]
  • 技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告
    技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告 ... [详细]
  • 动态壁纸 LiveWallPaper:让您的桌面栩栩如生(第二篇)
    在本文中,我们将继续探讨如何开发动态壁纸 LiveWallPaper,使您的桌面更加生动有趣。作为 2010 年 Google 暑期大学生博客分享大赛 Android 篇的一部分,我们将详细介绍 Ed Burnette 的《Hello, Android》第三版中的相关内容,并分享一些实用的开发技巧和经验。通过本篇文章,您将了解到如何利用 Android SDK 创建引人入胜的动态壁纸,提升用户体验。 ... [详细]
  • 在对WordPress Duplicator插件0.4.4版本的安全评估中,发现其存在跨站脚本(XSS)攻击漏洞。此漏洞可能被利用进行恶意操作,建议用户及时更新至最新版本以确保系统安全。测试方法仅限于安全研究和教学目的,使用时需自行承担风险。漏洞编号:HTB23162。 ... [详细]
  • 本文深入解析了WCF Binding模型中的绑定元素,详细介绍了信道、信道管理器、信道监听器和信道工厂的概念与作用。从对象创建的角度来看,信道管理器负责信道的生成。具体而言,客户端的信道通过信道工厂进行实例化,而服务端则通过信道监听器来接收请求。文章还探讨了这些组件之间的交互机制及其在WCF通信中的重要性。 ... [详细]
  • 使用 ListView 浏览安卓系统中的回收站文件 ... [详细]
  • 在Android平台中,播放音频的采样率通常固定为44.1kHz,而录音的采样率则固定为8kHz。为了确保音频设备的正常工作,底层驱动必须预先设定这些固定的采样率。当上层应用提供的采样率与这些预设值不匹配时,需要通过重采样(resample)技术来调整采样率,以保证音频数据的正确处理和传输。本文将详细探讨FFMpeg在音频处理中的基础理论及重采样技术的应用。 ... [详细]
  • 在处理 XML 数据时,如果需要解析 `` 标签的内容,可以采用 Pull 解析方法。Pull 解析是一种高效的 XML 解析方式,适用于流式数据处理。具体实现中,可以通过 Java 的 `XmlPullParser` 或其他类似的库来逐步读取和解析 XML 文档中的 `` 元素。这样不仅能够提高解析效率,还能减少内存占用。本文将详细介绍如何使用 Pull 解析方法来提取 `` 标签的内容,并提供一个示例代码,帮助开发者快速解决问题。 ... [详细]
  • 数字图书馆近期展出了一批精选的Linux经典著作,这些书籍虽然部分较为陈旧,但依然具有重要的参考价值。如需转载相关内容,请务必注明来源:小文论坛(http://www.xiaowenbbs.com)。 ... [详细]
  • Presto:高效即席查询引擎的深度解析与应用
    本文深入解析了Presto这一高效的即席查询引擎,详细探讨了其架构设计及其优缺点。Presto通过内存到内存的数据处理方式,显著提升了查询性能,相比传统的MapReduce查询,不仅减少了数据传输的延迟,还提高了查询的准确性和效率。然而,Presto在大规模数据处理和容错机制方面仍存在一定的局限性。本文还介绍了Presto在实际应用中的多种场景,展示了其在大数据分析领域的强大潜力。 ... [详细]
  • 第六章:枚举类型与switch结构的应用分析
    第六章深入探讨了枚举类型与 `switch` 结构在编程中的应用。枚举类型(`enum`)是一种将一组相关常量组织在一起的数据类型,广泛存在于多种编程语言中。例如,在 Cocoa 框架中,处理文本对齐时常用 `NSTextAlignment` 枚举来表示不同的对齐方式。通过结合 `switch` 结构,可以更清晰、高效地实现基于枚举值的逻辑分支,提高代码的可读性和维护性。 ... [详细]
  • 每日前端实战:148# 视频教程展示纯 CSS 实现按钮两侧滑入装饰元素的悬停效果
    通过点击页面右侧的“预览”按钮,您可以直接在当前页面查看效果,或点击链接进入全屏预览模式。该视频教程展示了如何使用纯 CSS 实现按钮两侧滑入装饰元素的悬停效果。视频内容具有互动性,观众可以实时调整代码并观察变化。访问以下链接体验完整效果:https://codepen.io/comehope/pen/yRyOZr。 ... [详细]
  • 在使用 SQL Server 时,连接故障是用户最常见的问题之一。通常,连接 SQL Server 的方法有两种:一种是通过 SQL Server 自带的客户端工具,例如 SQL Server Management Studio;另一种是通过第三方应用程序或开发工具进行连接。本文将详细分析导致连接故障的常见原因,并提供相应的解决策略,帮助用户有效排除连接问题。 ... [详细]
  • 求助:在CentOS 5.8系统上安装PECL扩展遇到问题
    在 CentOS 5.8 系统上尝试安装 APC 扩展时遇到了问题,具体表现为 PECL 工具无法正常工作。为了确保顺利安装,需要解决 PECL 的相关依赖和配置问题。建议检查 PHP 和 PECL 的版本兼容性,并确保所有必要的库和开发工具已正确安装。此外,可以尝试手动下载 APC 扩展的源代码并进行编译安装,以绕过 PECL 工具的限制。 ... [详细]
author-avatar
手机用户2502895961
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有