什么是 AWS 等同于 Firebase 实时数据库?

我现在正在做一个新的游戏项目,它将包括一个 React 本地前端和一个基于 Lambda 的后端。该应用程序需要一些实时功能,如活动用户记录,地理围栏等。

我一直在看 Firebase 的实时数据库,它看起来是一个实时数据同步的非常优雅的解决方案,但我不认为 AWS 有任何类似的东西。

对于只使用 AWS 服务的“无服务器”实时应用,我能想到的3种选择是:

选项1: 基于 WebSocket 的 AWS 物联网消息传递

这一点很明显,通过物联网 SDK 建立一个受管理的 WebSocket 连接。我在考虑触发 Lambdas 以响应入站和出站事件,并使用 WebSocket 作为实时层,像通常那样在应用程序客户机上构建自定义处理逻辑。

这样做的缺点是,至少与 Firebase 相比,我必须自己处理事件中的数据,这将在 WebSocket 之上添加另一层管理,并且必须与应用程序存储中的 API 数据层标准化。

优点:

  • 可伸缩的双向实时连接

缺点:

  • 只有当应用程序打开时才能工作
  • 需要实现消息结构
  • 要管理的多个传输层

选项2: 推式触发的重新取回

另一种选择是使用推送通知作为实时触发器,但是使用对 API 网关的常规 HTTP 请求来实际获取更新后的有效负载。

我喜欢这种方法,因为它只适用于一个传输层和应用程序状态的单一真实源。它也会触发更新时,应用程序没有打开,因为这些是推送通知。

缺点是,这需要进行大量的自定义工作,可能很难将推送通知映射到需要获取的数据。

优点:

  • 推送通知即使在应用程序关闭时也能正常工作
  • 真相的单一来源,传送层

缺点:

  • 大多数定制解决方案
  • 总体上将涉及更多的 HTTP 请求

选择3: 认知同步 这对我来说是新的,我不确定它是否真的可以从服务器接口。

认知同步提供用户状态同步。跨设备完成脱机支持,是认知 SDK 的一部分,我将使用无论如何。这听起来就像我正在寻找的,但是没有找到任何确凿的证据,关于是否可以修改,或“触发”,从 AWS 的更新,而不只是从一个设备。

优点:

  • 提供抽象的实时数据模型
  • 连接到认知用户记录 OOTB

缺点:

  • 不确定是否可以从 Lambdas 修改或更新

我想知道是否有人有在基于 Lambda 架构的 AWS 上进行实时操作的经验,以及您是否有关于最佳进行方式的意见?

71664 次浏览

I asked a similar question to the AWS Support, and this was their response.

My question to them:

What's the group of AWS services (if it's possible) to give that same in-browser real-time DBaaS feel like Firebase?

AWS Cognito seems to be great for user-accounts. Is there anything similar for the WebSockets / real-time DB part?

Their response:

To your question, Firebase is closest to the AWS service AWS MobileHub. You can check out more details below about mobilehub from below link.

https://aws.amazon.com/mobile/details/ https://aws.amazon.com/mobile/getting-started/

"AWS Cognito seems to be great for user-accounts. Is there anything similar for the WebSockets / real-time DB part?"

Amazon Dynamodb is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed cloud database and supports both document and key-value store models. Its flexible data model, reliable performance, and automatic scaling of throughput capacity, makes it a great fit for mobile, web, gaming, ad tech, IoT, and many other applications.

Amazon Dynamodb can be further optimized with Amazon DynamoDB Accelerator (DAX) which is a fully managed, highly available, in-memory cache that can reduce Amazon DynamoDB response times from milliseconds to microseconds, even at millions of requests per second.

For more information, please see below documentation.

https://aws.amazon.com/dynamodb/getting-started/ https://aws.amazon.com/dynamodb/dax/

Should you have any further questions, please do not hesitate to let me know.

Thanks.

Best regards,

Tayo O. Amazon Web Services

Check out the AWS Support Knowledge Center, a knowledge base of articles and videos that answer customer questions about AWS services: https://aws.amazon.com/premiumsupport/knowledge-center/?icmpid=support_email_category

Also while researching this answer I also found this, looks interesting:

https://aws.amazon.com/blogs/database/how-to-build-a-chat-application-with-amazon-elasticache-for-redis/

The comments to that article is interesting as well.

Jacob Wakeem: What advantage this approach have over using aws iot? It seems that iot has all these functionality without writing a single line of code and with server-less architecture.

Sam Dengler: The managed PubSub feature in the AWS IoT service is also a good approach to message-based applications, like the one demonstrated in the article. With Elasticache (Redis), customers who use Pub/Sub are typically also using Redis as a data store for other use cases such as caching, leaderboards, etc. With that said, you could also use ElastiCache (Redis) with the AWS IoT service by triggering an AWS Lambda function via the AWS IoT rules engine. Depending on how the message-based application is architected and how the data is leveraged, one solution may be a better fit than the other.

Check out AWS AppSync for some of these realtime and offline features using different data sources, including databases search and compute.

Sounds like AWS Serverless is most suited alternative.

Also wondering: AWS vs Firebase - Is It Even a Fair Fight?

AWS Amplify is AWS's modern answer to Firebase.

Fastest way to build mobile and web applications

AWS Amplify is a development platform for building secure, scalable mobile and web applications. It makes it easy for you to authenticate users, securely store data and user metadata, authorize selective access to data, integrate machine learning, analyze application metrics, and execute server-side code. Amplify covers the complete mobile application development workflow from version control, code testing, to production deployment, and it easily scales with your business from thousands of users to tens of millions. The Amplify libraries and CLI, part of the Amplify Framework, are open source and offer a pluggable interface that enables you to customize and create your own plugins.

I know this is an old question, but nowadays AWS offers AppSync... a service that destroys Firebase RDB in every aspect

AWS Amplify. You can find more information here: AWS Amplify

You could consider using supabase.

It is opensource and can be installed onto ec2 / docker containers. https://supabase.com/docs/guides/hosting/docker

I've found the hosted solution / free really poewrful to get up and running quickly. (yet to deploy to aws)