简体   繁体   English

发布到 SNS 主题/SQS 订阅的延迟?

[英]Latency on publishing to SNS Topic/SQS Subscription?

We are currently implementing a distributed Spring Boot microservice architecture on Amazon's AWS, where we use SNS/SQS as our messaging system:我们目前正在亚马逊的 AWS 上实现分布式 Spring Boot 微服务架构,我们使用 SNS/SQS 作为我们的消息传递系统:

Events are published by a Spring Boot service to an SNS FIFO topic using Spring Cloud AWS.事件由 Spring Boot 服务使用 Spring Cloud AWS 发布到 SNS FIFO 主题。 The topic hands over the events to multiple SQS queues subscribed to the topic, and the queues are then in turn consumed by different consumer services (again Spring Boot using Spring Cloud AWS).该主题将事件移交给订阅该主题的多个 SQS 队列,然后这些队列依次被不同的消费者服务使用(同样是使用 Spring Cloud AWS 的 Spring Boot)。

Everything works as intended, but we are sometimes seeing very high latency on our production services.一切都按预期工作,但我们有时会看到我们的生产服务延迟非常高。

Our product isn't released yet (we are currently in testing), meaning we have very, very low traffic on prod, ie, only a few messages a day.我们的产品尚未发布(我们目前正在测试中),这意味着我们的产品流量非常非常低,即每天只有几条消息。

Unfortunately, we see very high latency until a message is delivered to its subscribers after a long period of inactivity (typically up to 6 seconds, but can be as high as 60 seconds).不幸的是,我们看到在长时间不活动(通常长达 6 秒,但也可能高达 60 秒)后,将消息传递给其订阅者之前的延迟非常高。 Things speed up considerably afterwards with message delivery times dropping to below 100ms for the next messages being sent to the topic.之后事情会显着加快,下一个发送到主题的消息的消息传递时间下降到 100 毫秒以下。

Turning on logging on the SNS topic in AWS revealed that most of the delay for the first message is spent at the SNS part of things, where the SNS dwellTime roughly correlates with the delays we are seeing in message delivery.在 AWS 中打开 SNS 主题的登录显示,第一条消息的大部分延迟都花在了 SNS 部分,其中 SNS dwellTime时间与我们在消息传递中看到的延迟大致相关。 Spring Cloud AWS seems fine. Spring Cloud AWS 看起来不错。

Is this something expected?这是预料之中的事情吗? Is there something like a "cold startup" time for idle SNS FIFO topics (as seen when using AWS lambdas)?空闲 SNS FIFO 主题是否有“冷启动”时间(如使用 AWS lambdas 时所见)? Will this latency simply go away once we increase the load and heat up the topic?一旦我们增加负载并加热话题,这种延迟会消失吗? Or is there something we missed configuring?或者我们错过了什么配置?

We are using fairly standard SQS subscriptions, btw, no subscription throttling in place.我们正在使用相当标准的 SQS 订阅,顺便说一句,没有订阅限制。 The Spring Boot services run on a Fargate ECS cluster. Spring Boot 服务在 Fargate ECS 集群上运行。

Seems like AWS inactivates unused SNS topics somehow.似乎 AWS 以某种方式停用了未使用的 SNS 主题。 What we are doing now is, we are sending a "dummy" Keep-Alive message to the topic every ten minutes, which keeps the dwellTime reasonably low for us (<500ms)我们现在正在做的是,我们每十分钟向主题发送一条“虚拟”保持活动消息,这使我们的dwellTime时间保持在相当低的水平(<500 毫秒)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM