aws fargate

After passing my last certification, I asked myself how much time I spent studying cloud computing.

通过上一份认证后,我问自己自己花了多少时间研究云计算。

More than 100 days!

超过100天!

It also made me realize two things:

这也让我意识到两件事:

  1. There was no #100DaysOfCloud challenge没有#100DaysOfCloud挑战
  2. We have now enough content to create this challenge现在,我们有足够的内容来应对这一挑战

So I immediately contacted Alex Kallaway, the creator of #100DaysOfCode, to ask him if it was possible to create #100DaysOfCloud based on his challenge.

因此,我立即联系#100DaysOfCode的创建者Alex Kallaway,询问他是否有可能根据他的挑战创建#100DaysOfCloud。

And a few days later, the #100DaysOfCloud challenge was official:

几天后,#100DaysOfCloud挑战赛正式开始:

But something was missing.

但是缺少了一些东西。

If you already used the #100DaysOfCode hashtag, you know that your tweets are going to be retweeted at least three times by Twitter bots.

如果您已经使用#100DaysOfCode主题标签,则知道Twitter机器人将至少转发3次您的推文。

Because there were no bots for the new #100DaysOfCloud challenge, I decided to fix that problem.

因为没有新的#100DaysOfCloud挑战机器人,所以我决定解决此问题。

In this post, we're gonna see how I deployed my Twitter bot and why I choose to deploy it on AWS Fargate.

在本文中,我们将看到我如何部署Twitter机器人以及为什么选择在AWS Fargate上部署它。

Let's start!

开始吧!

先决条件 (Prerequisites)

If you want to follow along and run the commands below, be sure to:

如果要继续并运行以下命令,请确保:

  • Have an AWS account with access key and secret key

    拥有一个具有访问密钥和秘密密钥的AWS账户

  • Have Twitter API Authentication Credentials

    拥有Twitter API身份验证凭据

  • Install Docker on your machine

    在您的机器上安装Docker

  • Clone the repository from https://github.com/johanrin/100-days-of-cloud-bot

    从https://github.com/johanrin/100-days-of-cloud-bot克隆存储库

为什么选择AWS Fargate? (Why AWS Fargate?)

If you check my code, you’ll see that:

如果检查我的代码,您会看到:

  • The code is written in Python and use tweepy package该代码是用Python编写的,并使用tweepy包
  • The bot is always running (using a while loop)

    机器人始终处于运行状态(使用while循环)

  • There is a Dockerfile to build my image

    有一个Dockerfile构建我的映像

I will not explain all the code because that's beyond the scope of this post. But I did mention all the sources I used in the GitHub repository.

我不会解释所有代码,因为这超出了本文的范围。 但是我确实提到了我在GitHub存储库中使用的所有资源。

My idea was to deploy the Docker image in a container in the cloud with the following constraints:

我的想法是将Docker映像部署在云中的容器中,并具有以下限制:

  1. I don't want to spend much money我不想花很多钱
  2. I don't want to manage and operate servers我不想管理和操作服务器

Because I have credits on AWS, the first constraint was easy — go with AWS.

因为我对AWS有信誉,所以第一个约束很容易-选择AWS。

As for constraint number 2, I knew from the AWS Certified Developer - Associate course, that we could deploy serverless containers with AWS Fargate.

关于约束2,我从AWS Certified Developer-Associate课程知道,我们可以使用AWS Fargate部署无服务器容器。

Depending on your region, the pricing for AWS services can vary. It's often just a matter of a few cents, but I planned to run my bot for at least one year. So, every cent mattered.

根据您所在的地区,AWS服务的价格可能有所不同。 通常只需几美分,但我计划将我的机器人运行至少一年。 因此,每一分都很重要。

To see AWS Fargate pricing and minimize your cost, you can check the AWS documentation. I found that the cheapest region close to me was Ireland, so I decided to deploy my bot to AWS Fargate there.

要查看AWS Fargate定价并最大程度地降低成本,您可以查看AWS文档 。 我发现距离我最近的最便宜的地区是爱尔兰,因此我决定将我的机器人部署到那里的AWS Fargate。

我如何部署我的机器人? (How did I deploy my bot?)

Now that I've explained why I used AWS Fargate, let's see how I deployed my bot.

现在,我已经解释了为什么使用AWS Fargate的原因,让我们看看如何部署我的机器人。

There are two big steps to deploy a Docker image on AWS Fargate:

在AWS Fargate上部署Docker映像有两个重要步骤:

  1. Push the Docker image to Amazon Elastic Container Registry (ECR)将Docker映像推送到Amazon Elastic Container Registry(ECR)
  2. Deploy the Docker image on Fargate在Fargate上部署Docker映像

Let's explain each step in detail.

让我们详细解释每个步骤。

将Docker映像推送到Amazon Elastic Container Registry(ECR) (Push the Docker image to Amazon Elastic Container Registry (ECR))

  • In the root directory, build your image from the Dockerfile.

    在根目录中,从Dockerfile构建映像。

docker build . -t 100-days-of-cloud-bot
  • Authenticate your Docker to Amazon ECR.对您的Docker进行Amazon ECR身份验证。
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
  • Tag your image with the Amazon ECR repository.用Amazon ECR存储库标记图像。
docker tag 100-days-of-cloud-bot aws_account_id.dkr.ecr.region.amazonaws.com/100-days-of-cloud-bot
  • Push your image to Amazon ECR.将您的图像推送到Amazon ECR。
docker push aws_account_id.dkr.ecr.region.amazonaws.com/100-days-of-cloud-bot

在Amazon Fargate上部署Docker映像 (Deploy the Docker image on Amazon Fargate)

  • Open the Amazon ECS console first run wizard.

    打开Amazon ECS控制台首次运行向导 。

  • Click Configure in the custom container, complete with the following settings, and then select Update.

    单击自定义容器中的“ 配置 ”,完成以下设置,然后选择“ 更新”

Property Value
Container name container-100-days-of-cloud-bot
Image aws_account_id.dkr.ecr.region.amazonaws.com/100-days-of-cloud-bot
Memory Limits (MiB) Soft Soft limit | 512
Port mappings Container port: 80Protocol: tcp
CPU units 256
Environment variables
(Twitter API Authentication Credentials)
CONSUMER_KEY | Value | consumer_key
CONSUMER_SECRET | Value | consumer_secret
ACCESS_TOKEN | Value | access_token
ACCESS_TOKEN_SECRET | Value | access_token_secret
属性
容器名称 容器-100天的云机器人
图片 aws_account_id.dkr.ecr.region.amazonaws.com/100天云漫游器
内存限制(MiB) 软限制 512
端口映射 货柜码头 :80
通讯协议 :tcp
CPU单元 256
环境变量
(Twitter API身份验证凭据)
CONSUMER_KEY | 价值| Consumer_key
CONSUMER_SECRET | 价值| Consumer_secret
ACCESS_TOKEN | 价值| access_token
ACCESS_TOKEN_SECRET | 价值| access_token_secret
  • Click Edit in the Task definition section, complete with the following settings, and then select Save.

    单击“ 任务定义”部分中的“ 编辑 ”,完成以下设置,然后选择“ 保存”

Property Value
Task definition name task-definition-100-days-of-cloud-bot
Task memory 0.5GB (512)
Task CPU 0.25 vCPU (256)
属性
任务定义名称 任务定义100天云机器人
任务记忆 0.5GB(512)
任务CPU 0.25 vCPU(256)
  • Click Next.

    单击下一步

  • Click Edit in the Define your service section, complete with the following settings, and then select Save.

    点击定义您的服务部分中的编辑 ,完成以下设置,然后选择保存

Property Value
Service name service-100-days-of-cloud-bot
Number of desired tasks 1
Load balancer type None
属性
服务名称 服务100天的云机器人
所需任务数 1个
负载均衡器类型 没有

We don't need a load balancer here because of the Twitter API rate limit. Even if we scale-out our containers, Twitter's API will send us a 420 error message because the bot is being rate limited for making too many requests.

由于Twitter API速率限制,我们在这里不需要负载均衡器。 即使我们向外扩展容器,Twitter的API也会向我们发送420错误消息,因为该漫游器由于发出过多请求而受到速率限制。

  • Click Next.

    单击下一步

  • Edit your Cluster name with cluster-100-days-of-cloud-bot.

    使用cluster-100-days-cloud-bot编辑您的集群名称

  • Click Next.

    单击下一步

  • Review your configuration and click Create.

    查看您的配置,然后单击创建

That's it, the container is deployed on AWS Fargate!

就是这样,容器已部署在AWS Fargate上!

结论 (Conclusion)

You deployed your Twitter bot on AWS Fargate with only four steps.  

aws fargate_我如何在AWS Fargate上部署#100DaysOfCloud Twitter Bot相关推荐

  1. 我建了这个-现在呢? 如何在DigitalOcean Droplet上部署React App。

    by Andrea Stringham 通过安德里亚·斯特拉姆(Andrea Stringham) 我建了这个-现在呢? 如何在DigitalOcean Droplet上部署React App. (I ...

  2. linux mysql搭建禅道详细教程_如何在Linux服务器上部署禅道

    目前较受欢迎的开源项目管理软件:禅道. 这是一款国产的优秀开源项目管理软件,基于敏捷项目管理理念开发而成,操作简洁,能够很好地满足目前团队中的产品.开发.测试等人员的使用. 下面详细介绍如何在Linu ...

  3. 如何在Linux系统上部署接口测试环境

    作为一名软件测试人员,部署测试环境是我们日常工作的一部分,今天就简单整理下接口测试环境部署的步骤,希望能够帮助到大家. 今天为大家整理的接口测试环境部署涉及到Tomcat,JDK和数据库.目前能够提供 ...

  4. exi 虚拟服务器,图文教程:如何在ESXi主机上部署VMware Tools 10

    2015年9月VMware发布了VMware Tools 10.伴随着这次更新,VMware Tools 可能成为一款单独管理的产品.VMware Tools 10不再包含在ESXi的发布周期内,它拥 ...

  5. 如何在OpenStack Kolla上部署Tungsten Fabric(附14个常见的配置问题)

    首先,使用contil-kolla-ansible-deployer容器在OpenStack Kolla上部署Tungsten Fabric(注:原文为Contrail,本文以功能一致的Tungste ...

  6. linux部署jar项目报错_如何在Linux服务器上部署jar包

    启动程序方法 1.上传jar包到linux服务器下 2.启动jar包 ​前台模式 java –jar XXXX.jar(注意这个命令启动时,断开服务连接后,服务就关闭了) ​后台模式 nohup ja ...

  7. linux建立ss服务器,如何在linux服务器上部署ss服务

    满意答案 rqyfo 2017.12.13 采纳率:42%    等级:12 已帮助:19585人 ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息, ...

  8. 在Amazon Elastic Beanstalk上部署Spring Boot应用程序

    在此博客中,我们将看到如何在Amazon ElasticBeanstalk上部署Spring Boot应用程序. Amazon ElasticBeanstalk具有一个预配置的Java环境,可用于部署 ...

  9. 如何在 Amazon EKS 中部署 SR-IOV 设备插件

    前言 随着云技术和容器的发展,越来越多的基于容器集群的通信负载开始在公有云上运行,通信负载对网络性能要求极高,因此广泛使用 SR-IOV 技术来提升网络的吞吐量和减少抖动,同时降低应用的 CPU 开销 ...

最新文章

  1. datagrid的正反双向排序
  2. 智能车竞赛技术报告 | 智能车视觉 - 首都师范大学 - 首师智能视觉
  3. DPM Server切换
  4. deepblueai
  5. 说说我的工作——桌面支持
  6. js时间戳转成日期格式
  7. 20145302张薇 《信息安全系统设计基础》第14周学习总结
  8. jsmin 使用方法
  9. CSLA.Net3.6中使用CodeSmith
  10. pip install -q git+https://github.com/tensorflow/docs.git报错
  11. 读 zepto 源码之工具函数
  12. 一款简单微信小程序个人博客。后端基于SpringBoot实现
  13. 企业债和公司债的区别(表)
  14. 海康威视错误代码0xf_海康威视错误代码大全
  15. 操作系统,Ubuntu虚拟机编译裁剪内核
  16. 怎么用python编写个apk_【android】如何利用python做Android项目自动化构建,并一键实现构建结果发送到钉钉通知以及通过二维码下载apk或者其他处理等功能...
  17. Android仿微信气泡聊天界面设计
  18. Eclipse mars 实用快捷键
  19. Java基础之面向对象详解
  20. 海康摄像机相关设置资料--官方

热门文章

  1. 【js】common.jsp的使用
  2. java开发环境变量配置-JDK11-(win10),重启之后环境变量配置失效的解决办法
  3. java 匿名类调用方法_java – 从匿名类调用新定义的方法
  4. 微信小程序把繁琐的判断用Js简单的解决
  5. JS 函数 函数递归
  6. 学习 JavaScript (四)核心概念:操作符
  7. 使用hql动态创建对象问题
  8. 从特急到难产 光伏增补项目抢不抢630?
  9. GoldenGate的Logdump工具使用简介
  10. Linux下配置SNMP