奴隶为主人工作 - 分配工作

发布于 2024-08-06 02:21:42 字数 847 浏览 2 评论 0原文

对于我正在开发的一个新项目,我需要建立一个包含主服务器(主服务器)和多个工作站(从服务器)的集中式计算环境。

主站将收到多种类型的具有不同间隔和到期日期的作业订单,例如:

NAME        INTERVAL        EXPIRATION        OPERATIONS
Job A       5 m             9 d               2592
Job B       15 m            30 d              2880
Job C       30 m            90 d              4320
Job D       10 m            50 d              7200
Job E       10 m            20 d              2880
Job F       10 m            10 d              1440

从站将通过 API 接口请求新的作业来处理,一旦完成,它们将把存储在 SQLite 中的相关数据发送到服务器并请求一个新的作业。新工作。

我认为从服务器部分没有什么困难,但是我在主服务器方面面临一个小问题:为从服务器提供工作的最佳选择是什么?我有以下选项:

  1. 预先计算作业执行的时间并将其添加到数据库中。
  2. 用某种逻辑动态地服务于每项工作(MOD 运算符是这里可能的解决方案吗)?
  3. 随机提供工作。

说最后一个选项实际上不是一个选项可能是一件好事,因为我按操作次数(到期/间隔)收费,而且我认为如果我的客户为其他选项付费,他们不会太高兴。

我想听听您对我应该如何做这件事的想法。

For a new project that I'm working on I need to set up a centralized computing environment with a primary server (master) and several workstations (slaves).

The master will recieve several types of job orders with diferent intervals and expiration dates, example:

NAME        INTERVAL        EXPIRATION        OPERATIONS
Job A       5 m             9 d               2592
Job B       15 m            30 d              2880
Job C       30 m            90 d              4320
Job D       10 m            50 d              7200
Job E       10 m            20 d              2880
Job F       10 m            10 d              1440

The slaves will request new jobs to process via an API interface and once they are finished they will send the relevant data stored in SQLite to the server and request a new job.

I see nothing difficult with the slaves part, however I'm facing a small problem with the master server: what would be the best option to serve the jobs to the slaves? I've though of the following options:

  1. Pre-calculate and add to the database the times when the jobs will be executed.
  2. Serve each job dinamically with some sort of logic (is the MOD operator a possible solution here)?
  3. Randomly serve jobs.

It might be a good thing to say that this last option is really not an option since I'm charging by the number of operations (expiration / interval) and I think my clients wouldn't be too happy if they would be paying for others.

I would like to hear your thoughts on how I should do this.

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

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

发布评论

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

评论(1

甚是思念 2024-08-13 02:21:42

通过允许从属设备在有时间处理作业时请求作业,您将获得更好的吞吐量。

如果主节点分配作业,一些从节点可能会等待什么都不做,而另一些则超载。

如果从站在一段时间内没有返回答案,您还需要添加一些功能以使作业再次可用。

You will get a better through-put by allowing the slaves to request a job when they have time to process it.

If the master distributes the jobs, some slaves could be waiting doing nothing while others are overloaded.

You will also need to add some functionality to make a job available again, if the slave does not return an answer within a period of time.

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