有没有办法在AWS上用Python执行分布式代码?

发布于 2025-01-13 14:52:59 字数 617 浏览 3 评论 0 原文

我用 Python 创建了一个用于浏览网站的爬虫。它拉取许多链接,然后它必须访问每个链接拉取数据并解析和存储结果。

是否有一种简单的方法来运行分布在云中的脚本(例如AWS)?

理想情况下,我想要这样的事情(可能更困难,但只是为了提供一个想法)

run_in_the_cloud --number-of-instances 5 scraper.py

在过程完成后,实例被杀死,所以它不会花费更多的钱。

我记得我正在做类似的事情 和 < a href="/questions/tagged/java" class="post-tag" title="显示标记为'java'的问题" rel="tag">java 与

I created a scraper in Python that is navigating a website. It pulls many links and then It has to visit every link pull the data and parse and store the result.

Is there an easy way to run that script distributed in the cloud (like AWS)?

Ideally, I would like something like this (probably is more difficult, but just to give an idea)

run_in_the_cloud --number-of-instances 5 scraper.py

after the process is done, the instances are killed, so it does not cost more money.

I remember I was doing something similar with and with long time ago.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乜一 2025-01-20 14:52:59

如果您可以将抓取工具放入 Docker 映像中,那么使用 AWS ECS Fargate。只需创建一个任务定义并将其指向您的容器注册表,然后为您想要的任意数量的实例提交 runTask 请求。 AWS Batch 是另一个可用于轻松并行化容器实例的工具。

If you can put your scraper in a docker image it's relatively trivial to run and scale dockerized applications using AWS ECS Fargate. Just create a task definition and point it at your container registry, then submit runTask requests for however many instances you want. AWS Batch is another tool you could use to trivially parallelize container instances too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文