简体   繁体   English

负载平衡在集群中运行的Java应用程序

[英]Load Balancing a java application running in a cluster

I have multiple vms running all of the modules in the project. 我有多个运行项目中所有模块的虚拟机。 Each request created by the user has to be processed by all modules, but needs to be done only once. 用户创建的每个请求都必须由所有模块处理,但是只需要执行一次。 So if VM1 picks up a request then module1 can process the request partially, next VM1 or VM2 or any other VM in cluster can pick up and process for module2. 因此,如果VM1接收到请求,则module1可以部分处理该请求,下一个VM1或VM2或群集中的任何其他VM可以接收并处理module2。 And so on. 等等。

Since each VM is of limited capacity i would like to use a load balancer for allocating work among individual VM's. 由于每个VM的容量有限,因此我想使用负载平衡器在各个VM之间分配工作。

Are there load balancers(open source for java) available which can solve this or do i need to implement it using several load balancing algos(round robin,weighted etc) for solving my requirement? 是否有可用的负载均衡器(Java开源)可以解决此问题,或者我需要使用几种负载均衡算法(轮循,加权等)来实现它来解决我的需求?

Edit 1: 编辑1:

Each module is a java class which is independent in itself but needs previous modules to be done before its started.Each Vm is listening to a message bus. 每个模块都是一个Java类,它本身是独立的,但是需要在启动之前完成以前的模块。每个Vm都在侦听消息总线。 As and when a message appears in the bus any of the vm can pick up this and start working on it. 当总线上出现一条消息时,任何虚拟机都可以接听并开始处理它。

You can try HAProxy (TCP/HTTP loadbalancer ) which is open source, feature rich and quite widely used. 您可以尝试HAProxy (TCP / HTTP loadbalancer),它是开源的,功能丰富并且使用广泛。 Apart from good documentation you can find lots of information available. 除了好的文档,您还可以找到很多可用的信息。

Depending on the exact semantics of the problem you're trying to parallelize, you might get good results by chunking your problem into "work packets" of some size and keeping them in a central queue. 根据您要并行化的问题的确切语义,通过将问题分成一些大小的“工作包”并将它们放在中央队列中,可能会获得良好的结果。 Then, just have each VM poll a packet from said queue as soon as it finished the previous packet. 然后,让每个VM在完成前一个数据包后立即轮询来自该队列的数据包。 This is called self-scheduling. 这称为自调度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM