在扩大快速,频繁交易的需求不断增长的信息量,的世界,它是至关重要的,系统处理的数据变得可用。这就是为什么event-driven design pattern(一种架构模式围绕生产,检测建,消费,和反应,events)已经获得了普及,在过去的几年里。

正如我们经常与我们的客户,部署和维护一个事件驱动架构看到的是比较困难的,几乎总是需要定制开发。值得庆幸的是,从亚马逊的新服务名为Lambda将大大降低建立事件驱动系统的障碍。当与FME技术,这给你一个非常强大的的弹性加工转化的工具集hundreds支持的数据集。

拉姆达服务坐在数据和在AWS计算层之间。它允许开发人员建立动态事件驱动的应用程序提供的接口上传Node.js的代码,然后设置触发器在AWS运行的代码。触发器目前可以在Amazon S3上,亚马逊的Kinesis和亚马逊迪纳摩DB服务设置。正如所预期的,LAMBDA秤作为事件的规模,所以成本低,性能/可靠性高。

让我们通过一个场景设置了一个事件驱动的系统。我们将专注于处理是进入亚马逊S3存储桶的数据,因为这是最流行的工作流程,我们在这里安全软件看到。亚搏在线亚搏在线

场景概述:Amazon S3的触发器

下面是我们将实现工作流的高度概括。亚搏在线这是适合于具有基于文件的输入的任何FME工作流程。亚搏在线如果你希望你的自动化工作流程,如果工作流是罕见的它特别适合(例如亚搏在线每日更新web mapping tiles的,批量加工sensor data或装载LiDAR数据到数据库中)。

Lambda overview - New Page

相比正常FME工作流程的主要区别是,你的供应需求FME能力。亚搏在线自从你only need to pay for the FME compute time that you use,您可以极大地扩展了的短时间内进行处理。The result: you pay less for more compute power and get the processing done in a much shorter period of time.

亚搏在线工作流执行:链接AWS组件

让我们更加深入地了解实现这个工作流程所需的步骤。亚搏在线

Data processing Lambda - New Page

Step 1:文件被放置在InboundS3桶。

Step 2:在S3桶通知火灾和将事件发送到lambda函数。

Step 3:lambda函数(JavaScript代码)进行检查以查看是否FME云实例正在运行;如果不是,就启动它。它也发送消息与该事件的SQS队列的详细信息。

Step 4:在FME云实例(一次在线)会自动开始从队列中拉出SQS消息。的SQS消息包含S3的数据,这FME用途来下载的位置和处理数据。完成后处理后的数据被发送到outboundS3桶。

一步步骤:放在一起AWS LAMBDA,S3和FME云

Set up AWS S3 buckets

按照教程here设置您的AWS桶。这将引导您完成创建桶,设置IAM,并配置S3发布事件。

Set up Lambda Code

下面是LAMBDA代码提供FME云实例和发送消息到SQS队列。您将需要更新QUEUE_URL, , and .

的console.log( '加载事件');//需要VAR SQS QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/441807460849/lambda-processing-s3';VAR = AWS要求( 'AWS-SDK');VAR = SQS新AWS.SQS({区域: '我们 - 东 -  1'});VAR = HTTP要求( 'https' 时);exports.handler =函数(事件,上下文){//发送SQS消息上传到S3文件的细节。VAR PARAMS = {消息体:JSON.stringify(事件),QueueUrl:QUEUE_URL};sqs.sendMessage(PARAMS,函数(ERR,数据){如果(ERR){的console.log( '错误:', “失败发送消息” + ERR);context.done( '错误', “ERROR把SQS”);//与消息ERROR}其他{的console.log( '数据:',data.MessageId);context.done(NULL, '');// SUCCESS}});//检索实例的当前状态,看它是否已暂停。VAR选项= {主机: 'api.fmecloud.safe.com',亚搏在线端口:443,路径:“/ V1 /实例/
     
      .json', headers: {'Authorization': 'Bearer
      
       '}, method: 'GET' };var req = http.request(options, function(response){ console.log(response.statusCode + ':- Instance state response code.');response.on('data', function(d) { var jsonObj = JSON.parse(d);if (jsonObj.state === 'PAUSED'){ //If it is paused then launch the instance launchInstance();}else{ console.log('Instance already running.');} });});req.end();};// Launch instance if it is not paused.function launchInstance(){ var options = { host: 'api.fmecloud.safe.com', port: 443, path: '/v1/instances/
       
        /start', headers: {'Authorization': 'Bearer
        
         ', 'Content-Length': 0}, method: 'PUT' };var req = http.request(options, function(response) { console.log(response.statusCode + ':- Launch instance status response code.');});req.end();}
        
       
      
     

配置FME云工作流程亚搏在线

当。。。的时候FME Cloud实例上线时,一个工作区FME在每个引擎从SQS队列提取消息配置,从S3下载数据,处理该数据,然后将数据发送回S3。

2015-02-04_08-47-16

工作区是可供下载here,但如果你有兴趣的情况下,请contact support我们将很乐意提供帮助。

它要多少钱?

让我们运行一个快速的成本计算。假设我们有数据的120GB一天在未来,它需要大约40个小时的FME引擎计算时间来处理数据。

AWS Costs

S3 Storage Costs- $ 0.03每GB

数据的120GB存储在入站桶一天4小时: -

120GB *(4小时/ 24小时)* 0.03 =$0.60

500 GB的数据总是存储在出站斗: -

500GB * 0.03 =$15.00

Lambda Costs (Free)- 每月第一个1万个请求是免费的

SQS Costs (Free)- 第一百万亚马逊SQS每月请求是免费的


Total AWS Costs : $15.60 a month.


FME云成本

40小时neede FME引擎的处理时间d a day.Fourteen hours of FME Engine compute per hour can be delivered by the 16 core Enterprise instance.Three hours of theEnterpriseinstance therefore delivers 42 compute hours.

Compute time: 3 hours * $8 * 31 days =$744 a month

Outbound traffic: 20GB * $0.13 * 31 =$80.60


Total FME Cloud Costs: $824.60 a month


The total cost to process over 3.6TB of data a month is only $840.That not only gives you the software and the hardware, but also a fully monitored and maintained platform that is completely automated.Only two years ago this would have been unthinkable.

Event-driven workflows moving forward

The ability to essentially create micro-services using Lambda, to glue together different architectural components without having to worry about infrastructure, is going to have a dramatic effect on how we design applications.This workflow is merely a taste of what’s possible withFME Cloud, demonstrating the flexibility of Lambda and the power of wrappingAPIsaround infrastructure on the FME Cloud side.

Have you had experience with deploying an event-driven architecture?How do you plan on using AWS Lambda?

About Data About FME AWS Cloud Computing Data Transformation FME Cloud Lambda S3

Stewart Harper

Stewart is the Technical Director of Cloud Applications and Infrastructure at Safe.When he isn’t building location-based tools for the web, he’s probably skiing or mountain biking.

Comments

Leave a Reply

Your email address will not be published.Required fields are marked*

Related Posts