简体   繁体   English

AWS SQS和其他服务

[英]AWS SQS and other services

my company has a messaging system which sends real-time messages in JSON format, and it's not built on AWS our team is trying to use AWS SQS to receive these messages, which will then have DynamoDB to storage this messages im thinking to use EC2 to read this messages then save them any better solution ?? 我公司有一个消息传递系统,该消息传递系统以JSON格式发送实时消息,并且它不是基于AWS构建的,我们的团队正在尝试使用AWS SQS接收这些消息,然后将DynamoDB存储该消息,而我想使用EC2来存储这些消息。阅读此消息,然后保存它们任何更好的解决方案? or how to do it i don't have a good experience 或如何做,我没有很好的经验

First of All EC2 is infrastructure on Cloud, It is similar to physical machine with OS on local setup. 首先,EC2是云上的基础架构,它类似于具有本地设置操作系统的物理机。 If you want to create any application that will fetch the data from Amazon SQS(Messages in Json Format) and Push it in dynamodb(No Sql database), Your design is correct as both SQS and DynamoDb have thorough Json Support. 如果您想创建任何将从Amazon SQS(Json格式的消息)中获取数据并以dynamodb(无Sql数据库)推送数据的应用程序,则您的设计是正确的,因为SQS和DynamoDb都具有全面的Json支持。 Once your application is ready then you deploy that application on EC2 machine. 准备好应用程序后,便可以在EC2机器上部署该应用程序。

For achieving this, your application must have the asyc Buffered SQS consumer that will consume the messages(limit of sqs messages is 256KB), Hence whichever application is publishing messages size of messages needs to be less thab 256Kb. 为实现此目的,您的应用程序必须具有将使用消息的asyc Buffered SQS使用者(sms消息的限制为256KB),因此,无论哪个发布消息的应用程序,消息的大小都应小于256Kb。 Please refer below link for sqs consumer 请参考以下链接以了解sqs消费者

is putting sqs-consumer to detect receiveMessage event in sqs scalable 正在使sqs-consumer在sqs可伸缩中检测receiveMessage事件

Once you had consumed the message from sqs queue you need to save it in dynamodb, that you can easily do it using crud repository . 使用完来自sqs队列的消息后,您需要将其保存在dynamodb中,您可以使用crud仓库轻松地进行处理。 With Repository you can directly save the json in Dynamodb table but please sure to configure the provisioning write capacity based on requests, because more will be the provisioning capacity more will be the cost. 使用存储库,您可以直接将json保存在Dynamodb表中,但是请确保根据请求配置预配置写容量,因为更多的预配置容量将更多的花费。 Please refer below link for configuring the write capacity of table. 请参考下面的链接来配置表的写容量。

Dynamodb reading and writing units Dynamodb读写单元

In general, you'll have a setup something like this: 通常,您将进行如下设置:

在此处输入图片说明

The EC2 instances (one or more) will read your queue every few seconds to see if there is anything there. EC2实例(一个或多个)将每隔几秒钟读取一次队列,以查看是否有任何内容。 If so, they will write this data to DynamoDB. 如果是这样,他们会将这些数据写入DynamoDB。

Based on what you're saying you'll have less than 1,000,000 reads from SQS in a month so you can start out on the free tier for that. 根据您所说的,您一个月内从SQS读取的内容将少于1,000,000次,因此您可以从此免费开始。 You can have a single EC2 instance initially and that can be a very small instance - a T2.micro should be more than sufficient. 最初您可以有一个EC2实例,并且可以是一个很小的实例-T2.micro应该绰绰有余。 And you don't need more than a few writes per second on DynamoDB. 而且,您不需要在DynamoDB上每秒进行多次写入。

The advantage of SQS is that if for some reason your EC2 instance is temporarily unavailable the messages continue to queue up and you won't lose any of them. SQS的优势在于,如果由于某种原因您的EC2实例暂时不可用,则消息将继续排队,并且您不会丢失任何消息。

From a coding perspective, you don't mention your development environment but there are AWS libraries available for a pretty wide variety of environments. 从编码的角度来看,您没有提到您的开发环境,但是有许多适用于各种环境的AWS库。 I develop in Java and the code to do this would be maybe 100 lines. 我用Java开发和代码来完成,这将是也许 100线。 I would guess that other languages would be similar. 我猜想其他语言也会相似。 Make sure you look at long polling in the language you're using - it can help to speed up the processing and save you money. 确保以您使用的语言查看长时间的轮询-这有助于加快处理速度并节省资金。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Eventbridge 能否用于将 SQS 消息传递到其他 AWS 服务? - Can AWS Eventbridge be used to pass SQS message to other AWS services? AWS SQS队列是否彼此隔离? - Are AWS SQS queues isolated from each other? AWS SQS Maven 依赖性在运行时抛出 java.lang.NoClassDefFoundError: software/amazon/awssdk/services/sqs/SqsClient - AWS SQS Maven Dependency Throws java.lang.NoClassDefFoundError : software/amazon/awssdk/services/sqs/SqsClient On Runtime AWS SQS 和 SES 依赖库相互影响 - AWS SQS and SES dependency libraries effect each other SQS 与服务的通信 - SQS communication with services AWS Lambda Function无法访问其他服务 - AWS Lambda Function cannot access other services 我是否需要SQS队列才能将远程数据存储在Amazon Web Services(AWS)云中? - Do I need SQS queues to store remote data in the Amazon Web Services (AWS) cloud? 针对 AWS 的应用程序以及 Azure 的单一代码库,用于传递服务,例如服务总线、blob、SQS/SNS 等 - Single codebase for applications that target AWS as well as Azure for pass services such as service bus, blob, SQS/SNS etc 使用 AWS 服务 SQS、SES、Lambda 开发、测试和部署无服务器应用程序的最佳方法是什么 - What is the best way to develop, test and deploy serverless applications which uses AWS services SQS, SES, Lambda AWS SQS 的轮询策略 - Polling strategy for AWS SQS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM