小程序
传感搜
传感圈

Building and Scaling IoT Projects Quickly with Serverless Architecture

2022-11-16
关注

Building and Scaling IoT Projects Quickly with Serverless Architecture
Illustration: © IoT For All

So you’ve launched a new IoT product, perhaps using the IoT framework provided by AWS, Azure, or another major cloud provider, and your devices can now send and receive data from the cloud. Now, how do you process that data to get valuable insights, such as device health telemetry or user behavior tracking? There are a number of different ways to set up data processing infrastructure in the cloud that trade off control and complexity. Serverless architecture is ultimately a software design principle that allows you to build, scale, and run services without managing the infrastructure, and MistyWest is excited about how this “serverless” pattern can enable teams to rapidly build and scale cloud solutions.

To help you understand how applicable this is for IoT product solutions, we’re providing the following overview of the different architecture patterns and when you should consider going serverless for your project.

'Serverless architecture allows you to completely offload managing servers to the cloud providers while you can focus directly on your application code.' -MistyWest Click To Tweet

Using a Virtual Machine

Now, the old-school way of setting up a cloud pipeline, and the recommended way if you want more control, is to spin up a virtual machine (VM) in the cloud to run your processing code. Azure Virtual Machines, AWS EC2, or GCP Compute Engines are some common options. You get a virtual computer that can run code similar to running on your personal computer. However, the limitation of this route is that you will rapidly run out of processing power in a single VM, especially if you’re handling data from thousands of IoT devices.

To get more processing power, you can add more VMs and divide the processing work between many computers. Tools like Kubernetes and Docker Swarm let you orchestrate processing workloads across many machines, and cloud providers offer services like AWS Elastic Kubernetes Service and Google Kubernetes Engine to support orchestrating workloads across multiple machines in the cloud. Services like AWS Elastic Beanstalk or Azure App Services automate the setup and scaling of common web development frameworks like Django, Rails, and Node, and are great starting point services to help you manage them.

Setting up and configuring orchestration tools, however, can be complex, requiring a lot of time and expertise that doesn’t directly provide value for your customers. If you want to prototype quickly to deliver value to your customers and you know that your solution will scale, serverless may be the way to go.

What Is Serverless Architecture?

Serverless architecture allows you to completely offload managing servers to the cloud providers while you can focus directly on your application code. One of the more common architecture subsets is Functions-as-a-Service (FaaS). But serverless architecture provides much more – from databases and queue systems to event processing services, each cloud service provider offers a wide variety to meet your needs.

Figure 1 – Multiple Manually-Configured Servers

Benefits of Going Serverless

  1. Charging: One benefit is that serverless platforms tend to charge based on how often the serverless functions run and for how long, so you only pay for the compute time that you use. This can keep costs low during development while building in a way that automatically scales up during launch.

  2. Fast Response: Serverless functions also tend to respond quickly to spikes in demand as the platform automatically scales up the amount of compute power available to run the functions, then downscale when the load is reduced. This produces an efficient usage of resources, deploying compute power only when needed.

  3. Language Options: There is good support for a variety of programming languages, so you can very likely build your serverless functions in your language of choice. For example, AWS Lambda natively supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby, and provides a Runtime API to allow the use of other programming languages. Azure Functions support C#, Javascript, F#, Java, Powershell, Python, and Typescript.

  4. Bug Prevention: Building with serverless functions necessarily creates a stateless and hostless system, which can simplify reasoning about the system and prevent some complex bugs around state management.

  5. Data Pipeline: With your IoT framework, you can set up automated, event-driven data pipeline triggers and database storage. By additionally hooking in visualization frameworks or developing your internal dashboard, you can monitor the progress immediately.

  6. Pay for Less: If you have a VM spun up, you’re paying regardless of whether you’re using the full extent of those resources or if it’s just sitting idle. This isn’t ideal if your IoT device is infrequently sending small packets of data, and even if you have thousands of devices constantly transmitting data, there’s going to be a lot of idle time between packets, which will be quite inefficient. Utilizing a serverless framework allows you to pay only for what you use, and will handle the scaling for you without any configuration change needed – whether you have one device or a million devices. Additionally, if you’re using Azure, as originally proposed in the paper Serverless in the Wild, you’ll be able to dramatically reduce your cold starts by having it predict invocations.

Figure 2 – Functions Running on a Serverless Platform

Downfalls of Going Serverless

  1. Less Control: One downside of using a serverless platform is that you get less fine-grained control of the instance running the code as you don’t have control over the configuration of the underlying hardware. Limits on processing power, memory, and processing time in serverless environments can be a limitation, whereas in a VM you can vertically scale quite heavily.

  2. Long Latency: One other disadvantage is that because the platform handles scaling up the available compute power (i.e. spinning up more VMs to run functions) during demand spikes, you have less control of the latency that arises when users have to wait for a VM to spin up. This can sometimes cause long latency on the first request, known as “cold start latency” which could be a concern in highly latency-sensitive applications, though isn’t generally an issue.

Elastic Architecture

There are a number of cost comparisons around serverless architecture available on the web; we found Serverless Transformation on Medium and The Burning Monk’s analyses to be very helpful. Serverless architecture is highly applicable to IoT solutions and growing in popularity. With the billions of IoT devices used in the world today, having an elastic architecture is critical for getting to production quickly. Building with a serverless architecture will let you prototype quickly, fail fast, and beat your competition in the long run – just watch out for all of the under-the-hood properties in order to get the most for your buck.

Tweet

Share

Share

Email

  • Big Data
  • Connectivity
  • Consumer IoT
  • Cybersecurity
  • Data Analytics

  • Big Data
  • Connectivity
  • Consumer IoT
  • Cybersecurity
  • Data Analytics

参考译文
使用无服务器架构快速构建和扩展物联网项目
你推出了一个新的物联网产品,可能使用AWS、Azure或其他主要云提供商提供的物联网框架,你的设备现在可以从云发送和接收数据。那么,如何处理这些数据以获得有价值的见解,例如设备健康遥测或用户行为跟踪?有许多不同的方法可以在云中建立数据处理基础设施,以平衡控制和复杂性。无服务器架构最终是一种软件设计原则,它允许您在不管理基础设施的情况下构建、扩展和运行服务,而MistyWest对这种“无服务器”模式如何使团队能够快速构建和扩展云解决方案感到兴奋。为了帮助您理解这对于物联网产品解决方案的适用性,我们提供了以下不同架构模式的概述,以及您应该在什么情况下考虑为您的项目采用无服务器。现在,设置云管道的老派方法(如果希望获得更多控制,推荐使用这种方法)是在云中启动一个虚拟机(VM)来运行处理代码。Azure虚拟机、AWS EC2或GCP计算引擎是一些常见的选项。你得到一个虚拟计算机,它可以运行类似于在你的个人计算机上运行的代码。然而,这种路由的局限性是,您将迅速耗尽单个VM的处理能力,特别是当您正在处理来自数千个物联网设备的数据时。要获得更强的处理能力,可以添加更多vm并将处理工作分配给多台计算机。像Kubernetes和Docker Swarm这样的工具可以让您跨多台机器编排处理工作负载,云提供商提供AWS Elastic Kubernetes Service和谷歌Kubernetes Engine这样的服务,以支持在云中跨多台机器编排工作负载。像AWS Elastic Beanstalk或Azure App Services这样的服务可以自动设置和扩展常见的web开发框架,如Django、Rails和Node,它们是很好的起点服务,可以帮助你管理它们。然而,设置和配置编排工具可能是复杂的,需要大量的时间和专业知识,不能直接为客户提供价值。如果你想快速构建原型,为客户提供价值,并且你知道你的解决方案可以扩展,那么无服务器可能是正确的选择。无服务器架构允许您将服务器管理完全卸载给云提供商,同时可以直接专注于应用程序代码。一个更常见的体系结构子集是功能即服务(FaaS)。但无服务器体系结构提供的服务远不止这些——从数据库和队列系统到事件处理服务,每个云服务提供商都提供各种各样的服务来满足您的需求。在网络上有许多关于无服务器架构的成本比较;我们发现介质上的无服务器转换和燃烧和尚的分析非常有帮助。无服务器架构高度适用于物联网解决方案,越来越受欢迎。随着今天世界上使用的数十亿IoT设备,拥有一个弹性的架构对于快速进入生产是至关重要的。使用无服务器架构进行构建可以让您快速创建原型,快速失败,并从长远来看击败竞争对手——只要注意所有底层属性,以便最大限度地利用您的资金。
您觉得本篇内容如何
评分

评论

您需要登录才可以回复|注册

提交评论

iotforall

这家伙很懒,什么描述也没留下

关注

点击进入下一篇

农业气象站无线传输LED显示屏

提取码
复制提取码
点击跳转至百度网盘