在多个服务器上分布Java线程? [英] Distributing java threads over multiple servers?

查看:92
本文介绍了在多个服务器上分布Java线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Java很陌生,非常喜欢学习它.我制作的程序运行良好,但是在添加更多数据进行处理时会花费一些时间.我使它线程化,并确实大大加快了速度,但现在我正在考虑尝试进一步加快速度(显然,处理更长的时间需要处理更多的数据).仅供参考,我的程序在线程之间不共享任何数据,它获取列表的一项,并进行一些数学运算并将结果上传到数据库.理想情况下,一些工作计算机会获取列表中的一些项目,然后再进行工作,然后再进行更多工作,直到完成为止

I'm pretty new to java and really enjoying learning about it. I have made a program that is working well but takes a bit long when I add more data for it to process. I made it threaded and it really speeded it up alot, but now I'm thinking of trying to speed it up more(obviously more data it has to process the longer it takes). Just an fyi, my program does not share any data between threads,it gets one item of a list and does some math and uploads the result to a database. Ideally, a few work computers get a few items of the list and then do its work and then get more work until its done

我做了一些研究,发现了队列,并且不确定是否需要我的东西,或者那里是否还有其他东西(我也想维护工人的正直/监督可能对我来说太过分了.新手).我家里有4台计算机(有些Linux,mac和Windows ..,但如果这些解决方案特定于操作系统,则可以在所有非Linux系统上安装linux vm),并希望尝试让它们也开始从事此任务.我考虑过创建其他客户端需要处理的Java队列,但是我也看到了库(rabbitmq).我还简要介绍了网格计算.

I did a bit of research and found queues, and am not sure if its what I need or if there's something else out there(also I was thinking maintaining integrity/monitor of workers might be too much for me to write as a newbie). I have 4 computers at home(some Linux, mac and windows..but I can install linux vm's on all nonlinux systems if these solutions are os specific) and wanted to try to get them to start working on this task as well. I thought about creating Java queues that the other clients take a piece and process but I also saw libraries(rabbitmq). I also did briefly look over grid computing.

这是要走的道路还是有更好的办法?我不需要任何代码或任何东西,只想知道分配线程的解决方案是什么,或者在评估线程时使用哪些因素.

Is this the way to go or is there a better way? I don't need any code or anything just want to know what are the solutions to distributing threads or what factors to use when evaluating them.

推荐答案

仅需总结一下-您已经放大了,现在您要缩小 .从我的头顶开始:

Just to wrap up - you have already scaled-up, now you want to scale-out. From the top of my head:

  • :您可以创建Java Queue,它将自动分布在整个集群中.基本上,您运行的应用程序只有几个线程从队列中读取数据.兵马俑神奇地分配了该队列,因此感觉像本地对象.

  • terracotta: you can create a Java Queue that will be automatically distributed across the whole cluster. Basically you run the same application with few threads reading data from the queue. Terracotta magically distributes that queue so it feels like local object.

-类似的方法兵马俑,分布式数据结构和执行程序

hazelcast - similar approach to Terracotta, distributed data structures and executors

-发送消息还要花一些工作到JMS队列(再次排队),并有几个侦听器.每个侦听器或多或少是一个线程.可以在不同的计算机上设置侦听器.

jms - send a message with a piece of work to a JMS queue (queue, again) and have several listeners. Each listener is more-or-less a single thread. Listeners can be set up on different machines.

-映射/减少Java框架可轻松扩展大量数据.通常用于处理数据和汇总结果.

hadoop - Map/Reduce Java framework to easily scale out large amounts of data. Typically used to process data and aggregate results.

这篇关于在多个服务器上分布Java线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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