WCF,处理来自多个服务器的同时请求 [英] WCF, dealing with simultaneous requests from multiple servers

查看:212
本文介绍了WCF,处理来自多个服务器的同时请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作块,分成更小的块。我想将每个块分配给一个NumberCruncher实例(每个实例将托管在一个唯一的EndPoint,并将在服务器上的特定线程上运行)。然后,在返回结果为txt文件格式之前,指定EndPoint处的NumberCruncher实例将转到并压缩由客户端代理传递给它的那些数字。

I have a block of work which ive split into smaller blocks. I want to assign each block to an instance of NumberCruncher (Each instance would be hosted at a unique EndPoint and would be run on a specific thread on the server). The instance of NumberCruncher at the specified EndPoint would then go and crunch those numbers passed to it by the Client proxy, before returning the results in a txt file format.

从客户端,Im假设我需要保留2个线程安全列表,1包含链接到等待返回他们的结果的NumberCruncher的实例的EndPoint。对于正在等待分配更多工作的NumberCruncher实例,第二个?

From a client side, Im assuming i need to keep 2 threadsafe list, 1 containing the EndPoints linked to instances of NumberCruncher which are waiting to return their results. A 2nd for the instances of NumberCruncher which are waiting to be assigned more work?

关于向这些列表添加项目,如何处理来自服务器的多个请求?只有一个可以一次添加,所以im假设客户端需要发送一条消息回服务说是的您已成功添加到列表,现在停止请求添加。

Regarding adding items to these lists, how is it possible to deal with multiple requests from Servers? Only one can be added at a time, so im assuming the client need to send a message back to the service saying "Yes you were successfully added to the list, now stop requesting to be added."?

编辑

EDIT

我目前正尝试在一段时间内执行一些分析系列我收集。 Ive写了一个程序(Number Cruncher),它分割了我想要检查的不同参数,并将它们分配给不同的线程(由我的pc中的核心数决定)。每个线程然后运行带有分配的输入的Number Cruncher。不幸的是,这是一个愚蠢的时间在我的电脑,即使使用所有的核心。所以我想运行这个相同的程序,但在几个pc(服务器),并写一个程序,将工作分配给所有的服务器。每个模拟约需约1小时。所以,我看到520小时的计算时间(即不可行的单个pc)。

I'm currently trying to run some analysis on a time series i have collected. Ive written a program (Number Cruncher) which splits the different parameters i want to check and assigns them to different threads (determined by the number of cores in my pc). Each thread then runs Number Cruncher with the assigned input. Unfortunately this is taking a stupid amount of time on my pc even when using all the cores. So i wanted to run this same program but on several pc's (servers), and write a single program which would allocate work to all the servers. Each simulation takes about ~1hr. So im looking at 520hrs of computation time (ie not feasible for a single pc).

推荐答案

这个。

在WCF中,您可以控制实例数量(单个,每个会话和每个请求),以及实例是单线程还是多线程。但不是通过请求的线程亲和。

In WCF you do have some control over the number of instances (single, per-session and per-request) and whether an instance is single or multi-threaded. But not over thread-affinity of a request.

而且你不需要,在我看来你应该只配置每个请求的实例(很大程度上取决于编码和状态管理的细节)中。

And you don't need to, it seems to me you should just configure instance-per-request (depends very much on details of the coding and state-management).

您可以限制服务器以实现最大容量和可接受的延迟。如果你不需要,不要搞乱线程管理。

You can throttle the server to achieve maximum capacity and acceptable latency. Don't mess with thread-management if you don't have to.

编辑之后

您可以使用WCF为此,但它是一个分布式计算问题,专门的软件存在。

You can use WCF for this but it is a distributed computing problem, specialized software exists.

您可以将工作电脑作为服务器运行,这似乎是您目前的方向。但我会:

You could run the worker PCs as server, this seems to be your current direction. But I would:


  • 运行1个分割工作并管理工作项的服务器

    • 需要检查过期项目并重新发布


    • 需要配置为最大负载。可以是核心+ 2或核心-1

    这篇关于WCF,处理来自多个服务器的同时请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆