本文主要是介绍cloudflare_Cloudflare工作者简介,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
cloudflare
Cloud computing in its various incarnations — SaaS, PaaS, IaaS — has had big successes. Some of us still recall the $212 million purchase of PaaS provider Heroku in 2010, which at that time was — architecturally speaking — little more than a high-level deployment layer. It had a very posh gem for smooth and easy deployment of apps and frameworks like RoR, Python or Node apps running on Amazon’s infrastructure. The concept of Serverless Computing was born.
SaaS,PaaS,IaaS等各种形式的云计算已经取得了巨大的成功。 我们中有些人还记得2010年以2.12亿美元收购PaaS提供商Heroku的交易 ,从架构上来说,当时的交易只是高层部署层。 它具有非常出色的特性,可以轻松,轻松地部署在亚马逊基础设施上运行的应用程序和框架,例如RoR,Python或Node应用程序。 无服务器计算的概念由此诞生。
There have been a host of different models for cloud products ever since then. Various experiments have come and gone as providers looks for the sweet spot, with proliferation continuing and new terms being born, like BaaS and MBaaS.
从那时起,针对云产品就有许多不同的模型。 随着提供者寻找最佳位置,各种实验已经来去去了 ,并且扩散不断,新术语诞生了,例如BaaS和MBaaS。
Protocol Labs, a crypto startup looking to redefine the cloud model, collected $257 million in its 2017 ICO, breaking all records. Airtable, with its high-level, spreadsheet-meets-database products and api, reached a $1.1 billion valuation in its 2018 financing round.
一家旨在重新定义云模型的加密货币初创公司Protocol Labs在其2017年ICO中 筹集了2.57亿美元 ,打破了所有记录。 Airtable拥有高级电子表格会议数据库产品和api , 在其2018年融资中估值达到11亿美元 。
无服务器计算 (Serverless Computing)
Serverless computing is a subset term of cloud computing that makes a point of doing away with the classical server product, providing developers with a high-level environment to run their code, charged on an as-used basis, and freeing those developers from worrying about the underlying software stack.
无服务器计算是云计算的一个子集,它消除了传统的服务器产品,为开发人员提供了一个高级环境来运行其代码(按使用情况收费),并使这些开发人员免于担心基础软件堆栈。
Serverless computing has allowed further flexibility in paying for used processing power, rather than paying for pre-allocated packages as with classical cloud.
无服务器计算在支付使用的处理能力方面提供了更大的灵活性,而不是像传统云一样为预分配的软件包支付费用。
The term “serverless” is semantically wrong, because the code is still executed on a server, but users conceptually don’t have to deal with servers anymore. Provided certain conventions are adhered to, the underlying stack, and all the infrastructure and deployment issues, are handled by vendors.
术语“无服务器”在语义上是错误的,因为代码仍在服务器上执行,但是从概念上讲 ,用户不再需要与服务器打交道。 只要遵守某些约定,底层堆栈以及所有基础结构和部署问题均由供应商处理。
The main type of product that sprang out from this is FaaS — a cloud execution environment, or a runtime that allows deployment of code without any boilerplate. Amazon’s Lambda, Oracle Fn and Alibaba’s Function Compute are some examples.
由此产生的主要产品类型是FaaS,即云执行环境或允许代码部署而无需任何样板的运行时。 亚马逊的Lambda , Oracle Fn和阿里巴巴的Function Compute就是其中的一些例子。
云耀斑 (Cloudflare)
Cloudflare is a San Francisco company that was started nine years ago. It’s a Content Delivery Network that provides delivery of static assets for websites from its global network of edge nodes. It also provides firewall and DDOS protection, and has a reputation for the fastest DNS service on the internet.
Cloudflare是一家成立于9年前的旧金山公司。 这是一个内容交付网络 ,可从其全球边缘节点网络为网站提供静态资产。 它还提供防火墙和DDOS保护,并以互联网上最快的DNS服务而闻名。
When talking about Cloudflare, and what it brings to the arena of serverless computing, it’s necessary to add one more term to the list of cloud buzzwords we used here — edge computing.
在谈论Cloudflare及其对无服务器计算领域的意义时,有必要在我们在此处使用的云流行语列表中增加一个术语- 边缘计算 。
As explained on Wikipedia:
如维基百科上所述 :
edge computing is a distributed computing paradigm in which computation is largely or completely performed on distributed device nodes. Edge computing pushes applications, data and computing power (services) away from centralized points to locations closer to the user.*
边缘计算是一种分布式计算范例,其中计算主要或完全在分布式设备节点上执行。 边缘计算将应用程序,数据和计算能力(服务)从集中点推向更靠近用户的位置。*
Cloudflare工人 (Cloudflare Workers)
Cloudflare Workers are a peculiar, and powerful, incarnation of FaaS (function as a service), with code being instantly deployed to Cloudflare’s global network of nodes, to be executed as close as possible to the visitor.
Cloudflare Workers是FaaS(功能即服务)的一种独特而强大的化身,其代码可立即部署到Cloudflare的全球节点网络中,以尽可能接近访问者的方式执行。
As Kenton Varda has said on the Cloudflare blog:
正如Kenton Varda 在Cloudflare博客上所说 :
When responding to a user in New Zealand, your code should run in New Zealand. When crunching data in your database, your code should run on the machines that store the data. When interacting with a third-party API, your code should run wherever that API is hosted. When human explorers reach Mars, they aren’t going to be happy waiting a half an hour for your app to respond. Your code needs to be running on Mars.
当响应新西兰的用户时,您的代码应在新西兰运行。 处理数据库中的数据时,代码应在存储数据的计算机上运行。 与第三方API交互时,您的代码应在托管该API的任何位置运行。 当人类探险者到达火星时,他们将不乐意半小时等待您的应用做出响应。 您的代码需要在火星上运行。
Cloudflare Workers are a code execution environment designed on V8, the JavaScript engine designed for Google Chrome and used also by Opera, Node.js, Brave browser, Electron, and others.
Cloudflare Workers是在V8上设计的代码执行环境,V8是为Google Chrome设计JavaScript引擎,Opera,Node.js,Brave浏览器,Electron等也使用了它。
Workers use the Service Worker API — but the code resides on Cloudflare, not in the browser.
工作人员使用Service Worker API ,但是代码驻留在Cloudflare上,而不是在浏览器中。
They can “modify your site’s HTTP requests and responses, make parallel requests, and even reply directly from the edge”. This means that, if we were up for it, our application could reside on the CDN.
他们可以 “修改站点的HTTP请求和响应,进行并行请求,甚至直接从边缘进行答复”。 这意味着,如果我们坚持不懈,我们的应用程序可以驻留在CDN上。
This also means that, while we run dynamic JavaScript code that’s not server-side code in the classical sense, and it has a much better latency both in comparison to server-side apps and to classical FaaS services, our code is still not running in the browser, which means it’s not open to the public.
这也意味着,尽管我们运行的动态JavaScript代码不是传统意义上的服务器端代码,并且与服务器端应用程序和传统FaaS服务相比,其延迟要好得多,但我们的代码仍未在浏览器,这意味着它不向公众开放。
According to the words of its lead developer, Workers are the beginning of something that could develop into much more refined products in the future.
按照其主要开发人员的话来说,工人是未来可能发展成为更精致产品的起点。
In many cases, perceived speed and efficiency are as good as if the execution was happening in the visitor’s browser, but without the processing overhead. It all happens in the cloud.
在许多情况下,感知的速度和效率与在访问者的浏览器中执行操作一样好,但是没有处理开销。 这一切都发生在云中。
Comparable technology (which was available so far to users of NGINX) is Lua scripting — with the difference that Cloudflare executes workers’ code on its network of edge nodes, closest to the visitor.
可比较的技术(到目前为止,NGINX的用户可以使用)是Lua脚本编写 -区别在于Cloudflare在其最靠近访客的边缘节点网络上执行工作人员的代码。
Cloudflare Workers can be tested, quick and dirty, on the Cloudflare Workers Playground.
Cloudflare Workers可以在Cloudflare Workers Playground上进行快速,肮脏的测试。
潜在用途 (Potential Uses)
Cloudflare has uploaded a number of code examples to a GitHub repo. Among them is a Slack bot, which fetches prices or cryptocurrencies from CoinMarketCap and caches them on the Cloudflare infrastructure. The code is very simple, and is available here. It demonstrates the main advantage of Cloudflare Workers — the simplicity of doing away with dealing with the entire software stack underneath the application.
Cloudflare已将许多代码示例上传到GitHub存储库 。 其中有一个Slack机器人 ,它从CoinMarketCap获取价格或加密货币并将其缓存在Cloudflare基础设施上。 该代码非常简单,可在此处获得 。 它展示了Cloudflare Workers的主要优点-消除了处理应用程序下的整个软件堆栈的简便性。
Cloudflare Workers leave developers free to focus on the application logic.
Cloudflare Workers让开发人员可以自由地专注于应用程序逻辑。
Then there’s the more advanced example — the edge caching solution for WordPress — which gives a polished solution for caching, and purging the HTML output of WordPress, by putting together Cloudflare Workers, Workers KV (key-value store), and a plugin for WordPress, which all work in concert to make it possible to bypass the cache in case some cookies are present, to make atomic cache purging possible, and so on.
然后是一个更高级的示例-WordPress的边缘缓存解决方案-通过将Cloudflare Workers,Workers KV(键值存储)和WordPress插件放在一起,提供了完善的缓存解决方案并清除WordPressHTML输出。 ,所有这些都可以协同工作,从而可以在存在某些Cookie的情况下绕过缓存,从而可以进行原子缓存清除等。
You can find out more about this example here.
您可以在此处找到有关此示例的更多信息。
Then there are code examples of using custom logic to put a layer of protection between the origin website and the Internet.
然后是使用自定义逻辑在原始网站和Internet之间放置一层保护的代码示例 。
There is an example of using workers logic to rewrite 3rd-party scripts included in the web page HTML, to origin URLs with content hash, and then extending their browser cache, and also caching it on Cloudflare edge nodes — so there’s no need for three round trips to third-party servers for each script.
有一个示例,使用工作程序逻辑重写网页HTML中包含的第三方脚本 ,将其包含内容哈希值的原始URL,然后扩展其浏览器缓存,并将其缓存在Cloudflare边缘节点上,因此不需要三个每个脚本往返于第三方服务器。
This can make a big performance difference in some cases, and the beauty of it is that workers use JavaScript — which means there’s a rich programmable interface for conjuring all the power of the Cloudflare infrastructure to do our bidding.
在某些情况下,这可能会带来很大的性能差异,其美妙之处在于,工人使用JavaScript -这意味着存在一个丰富的可编程接口,可以利用Cloudflare基础架构的所有功能来进行投标。
There are other code examples in their repository.
他们的存储库中还有其他代码示例。
怎么做的 (How It’s Done)
When we open the Cloudflare dashboard, there’s a Workers menu item among the icon-menu items on the top.
当我们打开Cloudflare仪表板时,顶部的图标菜单项中有一个Workers菜单项。
To start, we need to open the Workers dashboard link in the top, and we will need to set up a subdomain for our workers:
首先,我们需要打开顶部的Workers仪表盘链接,并且需要为我们的worker设置一个子域:
Then we’ll be presented with the workers dashboard, where we’ll be able to deploy new workers, monitor thier usage, and so on.
然后,我们将看到工作人员仪表板,在这里我们将能够部署新工作人员,监视其使用情况等。
There’s also an editor, which we can use to edit the logic of the workers:
还有一个编辑器,我们可以使用它来编辑工作程序的逻辑:
As we said, Workers use the JavaScript V8 engine, and — obviously — JavaScript syntax. The documentation is solid and detailed, and has a number of templates so we can jump-start our work.
如前所述,Workers使用的是JavaScript V8引擎以及JavaScript语法。 该文档坚实而详细,并具有许多模板,因此我们可以立即开始工作。
等等,还有更多! (Wait, There’s More!)
For those of us who want the ability to put more logic into this layer, and want to squeeze more performance from this infrastructure, there’s more. In October 2018, Cloudflare announced support for WebAssembly for Workers — which means support for compiled languages like C, C++ and Rust. This makes Workers potentially very serious, if not game-changing contender in this space.
对于那些想要在此层中添加更多逻辑并希望从此基础架构中获取更多性能的人来说,还有更多的东西。 在2018年10月, Cloudflare宣布了对Workers WebAssembly的支持,这意味着对C,C ++和Rust等编译语言的支持。 如果不改变游戏规则,这可能会使工作人员非常认真,甚至无法改变游戏规则。
结论 (Conclusion)
Serverless computing, with the conveniences it offers, is grabbing the attention of more and more developers. It gives them freedom to focus on application logic, and not to have to worry about the underlying libraries and software infrastructure.
无服务器计算及其带来的便利,正吸引越来越多的开发人员的注意力。 它使他们可以自由地专注于应用程序逻辑,而不必担心基础库和软件基础结构。
Those of us who’ve had to handle hundreds of megabytes of npm libraries, who encountered the mess with versions of different dependencies, who had to install and work with Ruby Version Manager, or PyEnv, virtualenv, and similar delicacies, know the pain, and know that resolving these issues can take 80% of one’s work.
我们中那些不得不处理数百兆字节的npm库,遇到了各种依赖版本的混乱,不得不安装并使用Ruby Version Manager或PyEnv ,virtualenv以及类似的美味佳肴的人们,都深感痛苦,并且知道解决这些问题可能需要80%的工作。
Serverless cloud offerings available today have found their market, and Cloudflare Workers are one of the most interesting products in this niche. I hope you’ve found this introduction useful!
当今可用的无服务器云产品已经找到了市场,Cloudflare Workers是该细分市场中最有趣的产品之一。 希望您对本介绍很有帮助!
翻译自: https://www.sitepoint.com/cloudflare-workers/
cloudflare
这篇关于cloudflare_Cloudflare工作者简介的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!