doudiemei2013
doudiemei2013
2017-08-06 06:54

多服务器处理

已采纳

I have the following goal to complete. Suppose I have the following set

1,2,3,4,5,6

And then 3 conditions

the first number must be even
the second number must be odd
the sum of first 3 numbers must be 12

To find the proper set my goal is to generate random sets and check if they meet the conditions.

1,3,2,5,4,6 - 0 conditions
2,4,3,5,6,1 - 1 condition
2,3,4,5,6,1 - 2 conditions
4,5,3,2,6,1 - 3 conditions. All conditions met, this is our set

This is a very basic example, it will be a lot more data and a lot more conditions. Why am I using this way to find the set? Because having so many rules will be impossible to find the proper set and sometimes is impossible to find a set to meet all conditions so I will have a validation that will allow, for example, a set of more than 80% conditions met.

So I want to process this on multiple servers until I found a valid set(s). Probably I will use Amazon s3 instances.

I was looking into RabbitMQ and Celery but as far as I understood, they're more like a queue setup, not parallel processing. Also, I will probably need to write this in PHP and node.js

I was also thinking to have a master server and slave servers. The slave servers will start to generate and validate sets and will send the result to master using rabbit me. Once a set is found, the master will shut down the slave servers.

Not sure if this is the proper approach (both professionally and optimization wise)

What software should I use and what is a good way to implement this?

Thanks!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douchuituo3032 douchuituo3032 4年前

    I was also thinking to have a master server and slave servers. The slave servers will start to generate and validate sets and will send the result to master using rabbit me. Once a set is found, the master will shut down the slave servers.

    I think your approach is going to work. RabbitMQ is about messages, message passing is a tool to organize parallel processing.

    Your Task Generator (master) sends tasks (RabbitMQ messages) into the worker queue. Your processors (slaves) are subscribed to the queue. They can fetch task messages from the queue and start generating sets. Once generated, they send the result back to the master node. It can issue subsequent tasks based on what results it receives, ie generate sets of higher value from now or enough, stop work (those ones should go into different command topic that slaves are also subscribed to).

    点赞 评论 复制链接分享