简体   繁体   English

在AWS中部署机器人实例

[英]Deploying bot instances in AWS

I have no experience with AWS or bot deployment for production, so I'm looking for some suggestions on best practices. 我没有用于生产的AWS或机器人部署的经验,因此我正在寻找有关最佳实践的建议。

The project is a simple Twitter automation bot written as a node.js application. 该项目是一个简单的Twitter自动化机器人,编写为node.js应用程序。 Currently I am using Cloud9 in AWS to host it, but I feel this is likely not the most effective means. 目前,我正在AWS中使用Cloud9托管它,但是我认为这可能不是最有效的方法。

What I need: 我需要的:

  • Ability to easily deploy the bot/codebase. 能够轻松部署机器人程序/代码库。
  • Multiple instances so I can deploy a new instance for each user. 多个实例,因此我可以为每个用户部署一个新实例。
  • Ease of access to logs and updates. 易于访问日志和更新。
  • Usage reporting. 使用情况报告。
  • Ability to tie into a front end for users. 能够绑定到用户的前端。

I'd like to use AWS if possible to familiarize myself with the platform, but open to any suggestion that I can incorporate an easy workflow. 如果可能的话,我想使用AWS来熟悉该平台,但是对于任何建议我可以合并一个简单的工作流程的建议,我都持开放态度。

Current workflow to deploy new bot: 当前部署新机器人的工作流程:

  1. Create Cloud9 EC2 instance 创建Cloud9 EC2实例
  2. Install dependencies 安装依赖项
  3. Git clone from repository 从存储库克隆Git
  4. Edit configuration with users' access keys 使用用户的访问键编辑配置
  5. Run bot from console 从控制台运行机器人
  6. Leave running in background 在后台运行

This has been very easy thus far, but I just don't know if its practical. 到目前为止,这非常容易,但是我不知道它是否可行。 Appreciate any advice! 感谢任何建议!

Given that the bot needs to be constantly running (ie it can't just be spun up on-demand for a couple minutes, which rules out AWS Lambda) and that each user needs their own, I'd give AWS ECS a try. 鉴于该机器人需要持续运行(即,它不能按需启动几分钟,而这排除了AWS Lambda)并且每个用户都需要自己的机器人,因此我将尝试AWS ECS。

Your initial setup will look something like this: 您的初始设置将如下所示:

  1. First, create a Docker image to run your bot, and load it into ECR or Docker Hub . 首先, 创建一个Docker映像来运行您的机器人,并将其加载到ECRDocker Hub中
  2. Set up ECS. 设置云服务器 I recommend using AWS Fargate so you don't have to manage a VPC and EC2 instances just to run your containers. 我建议使用AWS Fargate,这样就不必仅运行容器就可以管理VPC和EC2实例。 You'll want to create your task definition using your bot Docker image. 您将要使用机器人Docker映像创建任务定义
  3. Run new tasks as needed using your task definition. 使用任务定义根据需要运行新任务。 This could be done via the AWS API, AWS SDK, in the AWS console, etc. 这可以通过AWS API,AWS SDK,AWS控制台等来完成。

Updating the bots would just involve updating your Docker image and task definition, then restarting the tasks so they use the new image. 更新机器人仅涉及更新Docker映像和任务定义,然后重新启动任务,以便它们使用新映像。

You should be able to set up logging and monitoring/alarming with CloudWatch for your ECS tasks too. 您还应该能够使用CloudWatch为您的ECS任务设置日志记录和监视/警报。

Usage reporting depends on what exactly you want to report. 使用情况报告取决于您要报告的内容。 You may get all you need from CloudWatch events/metrics, or you may want to send data from your containers to some storage solution (RDS, DynamoDB, S3, etc.). 您可能会从CloudWatch事件/指标中获得所需的一切,或者可能希望将数据从容器发送到某个存储解决方案(RDS,DynamoDB,S3等)。

Tying a front end to the bots depends on how the bots are set up. 将前端绑定到漫游器取决于漫游器的设置方式。 If they have REST servers listening to a particular port, for example, you'd be able to hit that if they're running on ECS. 例如,如果他们的REST服务器正在侦听特定端口,那么如果它们在ECS上运行,则可以实现这一点。

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

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