gpt4 book ai didi

amazon-web-services - Amazon Elastic Beanstalk 工作层

转载 作者:行者123 更新时间:2023-12-03 23:32:13 24 4
gpt4 key购买 nike

给定一个网络请求,我需要做一些异步作业处理,我将定期轮询直到它完成。我有整个堆栈并在本地运行,但我无法从概念上理解如何将其转移到 EBS 工作层。我在本地将 Django 与 Celery 和 RabbitMQ 一起使用,并且成功地将 RabbitMQ 换成了 Amazon SQS。但是,当我尝试创建一个工作层时,该层将在与 webapp 相同的 RDS 数据库上运行,但没有成功。我被困在可以将消息排队但无法从队列中读取它们的地方。我需要使用这些消息对数据库执行一些昂贵的操作并为消费者准备结果。有没有我遗漏的建筑作品?我如何以及在哪里可以获得 celery 守护进程来处理 SQS 消息?

最佳答案

来自 Elastic Beanstalk documentation :

When you launch an AWS Elastic Beanstalk environment, you choose an environment tier, platform, and environment type. The environment tier that you choose determines whether AWS Elastic Beanstalk provisions resources to support a web application that handles HTTP(S) requests or a web application that handles background-processing tasks.

AWS Elastic Beanstalk installs a daemon on each Amazon EC2 instance in the Auto Scaling group to process Amazon SQS messages in the worker environment tier. The daemon pulls data off the Amazon SQS queue, inserts it into the message body of an HTTP POST request, and sends it to a user-configurable URL path on the local host. The content type for the message body within an HTTP POST request is application/json by default.

From a developer perspective, the application running on the worker tier is just a plain web service. It will receive calls from AWS Elastic Beanstalk daemon provisioned for you on the instance.

The requests are sent to the HTTP Path value that you configure. This is done in such a way as to appear to the web application in the worker environment tier that the daemon originated the request. In this way, the daemon serves a similar role to a load balancer in a web server environment tier.

The worker environment tier, after processing the messages in the queue, forwards the messages over the local loopback to a web application at a URL that you designate. The queue URL is only accessible from the local host. Because you can only access the queue URL from the same EC2 instance, no authentication is needed to validate the messages that are delivered to the URL.

A web application in a worker environment tier should only listen on the local host. When the web application in the worker environment tier returns a 200 OK response to acknowledge that it has received and successfully processed the request, the daemon sends a DeleteMessage call to the SQS queue so that the message will be deleted from the queue. (SQS automatically deletes messages that have been in a queue for longer than the configured RetentionPeriod.) If the application returns any response other than 200 OK or there is no response within the configured InactivityTimeout period, SQS once again makes the message visible in the queue and available for another attempt at processing.

关于amazon-web-services - Amazon Elastic Beanstalk 工作层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23238366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com