分布式事务和/或群集中共享数据的Java解决方案 [英] Java Solutions for Distributed Transactions and/or Data Shared in Cluster

查看:219
本文介绍了分布式事务和/或群集中共享数据的Java解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

群集/分发Java服务器应用程序的最佳方法是什么?
我正在寻找一种方法,允许您通过添加更多应用程序服务器和更多数据库服务器来水平扩展。

What are the best approaches to clustering/distributing a Java server application ? I'm looking for an approach that allows you to scale horizontally by adding more application servers, and more database servers.


  • 您会建议采用哪些技术(软件工程技术或特定技术)来解决此类问题?

  • 您使用哪些技术设计持久层以扩展到许多读者/作者
    扩展应用程序事务并扩展对共享数据的访问(最佳方法是消除共享数据;可以应用哪些技术来消除共享数据)。

  • 似乎需要不同的方法,具体取决于你的交易是读还是重写,但我觉得如果你可以优化一个写重的应用程序,这个应用程序对于阅读也是有效的

最佳解决方案允许您为单个节点编写Java应用程序,并希望隐藏访问/锁定共享数据的大部分细节。

The "best" solution would allow you to write a Java application for a single node and hopefully "hide" most of the details of accessing/locking shared data.

在分布式环境中,最困难的问题总是归结为多个事务访问共享数据。似乎有两种常见的并发交易方法。

In a distributed environment the most difficult issue always comes down to having multiple transactions accessing shared data. There seems like there's 2 common approaches to concurrent transactions.



  1. 软件事务内存(STM)AKA乐观并发,如果事务发现共享状态,则在提交期间回滚事务已更改(以后可以重试该事务)。
    哪种方法可以更好地扩展,分布式系统的权衡是什么?

  1. Explicit locks (which is extremely error prone and slow to coordinate across multiple nodes in a distributed system)
  2. Software transactional memory (STM) AKA optimistic concurrency where a transaction is rolled back during a commit if it discovers that shared state has changed (and the transaction can later be retried). Which approach scales better and what are the trade-offs in a distributed system?

我一直在研究扩展解决方案(以及提供如何缩放的示例的一般应用程序),例如:

I've been researching scaling solutions (and in general applications that provide an example of how to scale) such as:


  1. Terracotta - 通过使用Java的并发锁定机制(synchronized,ReentrantReadWriteLocks)扩展Java内存模型以包含分布式共享内存来提供透明扩展。

  2. Google App Engine Java - 允许您编写Java(或python)应用程序,这些应用程序将分布在云服务器中,您可以在其中分发服务器处理事务,并使用BigTable存储持久数据(不确定访问共享数据的事务或处理锁定争用,以便能够有效地扩展)

  3. Darkstar MMO Server - Darkstar是Sun的开源MMO(大型多人在线) )游戏服务器以线程事务方式缩放事务,允许给定事务仅运行一定量并提交,如果需要很长时间,它将回滚(有点像软件事务存储器)。他们一直在研究支持多节点服务器设置以进行扩展。

  4. Hibernate的乐观锁定 - 如果您使用Hibernate,您可以使用其乐观并发支持来支持软件事务内存类型行为

  5. Apache CouchDB 应该扩展给许多读者/ writer DB在网格配置中自然而然。 (有一个很好的例子说明如何管理锁定数据或确保事务隔离?):

  6. JCache - 通过将结果缓存到可以在Google appengine中使用的常见查询来扩展读取繁重的应用程序,以访问memcached并缓存其他经常读取的数据。

  1. Terracotta - provides "transparent" scaling by extending the Java memory model to include distributed shared memory using Java's concurrency locking mechanism (synchronized, ReentrantReadWriteLocks).
  2. Google App Engine Java - Allows you to write Java (or python) applications that will be distributed amongst "cloud" servers where you distribute what server handles a transaction and you use BigTable to store your persistent data (not sure how you transactions that access shared data or handle lock contentions to be able to scale effectively)
  3. Darkstar MMO Server - Darkstar is Sun's open source MMO (massively multiplayer online) game server they scale transactions in a thread transactional manner allowing a given transaction to only run for a certain amount and committing and if it takes to long it will rollback (kinda like software transactional memory). They've been doing research into supporting a multi-node server setup for scaling.
  4. Hibernate's optimistic locking - if you are using Hibernate you can use their optimistic concurrency support to support software transactional memory type behavior
  5. Apache CouchDB is supposed to "scale" to many reader/writer DB's in a mesh configuration naturally. (is there a good example of how you manage locking data or ensuring transaction isolation?):
  6. JCache - Scaling "read" heavy apps by caching results to common queries you can use in Google appengine to access memcached and to cache other frequently read data.

Terracotta似乎是最完整的解决方案,因为您可以轻松修改现有服务器应用程序以支持扩展(在定义@Root对象之后)和@ AutoLockRead / Write方法)。问题是真正从分布式应用程序中获得最大的性能,分布式系统的优化实际上并不是真的,你必须设计它,知道对象访问可能被网络I / O阻止。

Terracotta seems to be the most complete solution in that you can "easily" modify an existing server application to support scaling (after defining @Root objects and @AutoLockRead/Write methods). The trouble is to really get the most performance out of a distributed application, optimization for distributed systems isn't really an after thought you kinda have to design it with the knowledge that object access could potentially be blocked by network I/O.

为了正确扩展它似乎总是归结为分区数据和负载平衡事务,例如给定的执行单元(cpu core - > thread - > distributed application节点 - >数据库主节点)

To scale properly it seems like it always comes down to partitioning data and load balancing transactions such that a given "execution unit" (cpu core -> thread -> distributed application node -> DB master node)

似乎通过群集使任何应用程序正确扩展您需要能够根据数据访问读取对事务进行分区/写。人们提出了哪些解决方案来分发他们的应用程序数据(Oracle,Google BigTable,MySQL,数据仓库),以及一般如何管理分区数据(许多写入主数据,以及更多读取数据库等)。

It seems like though to make any app scale properly by clustering you need to be able to partition your transactions in terms of their data access reads/writes. What solutions have people come up with to distribute their applications data (Oracle, Google BigTable, MySQL, Data warehousing), and generally how do you manage partitioning data (many write masters, with many more read DBs etc).

在扩展数据持久层方面,在将数据划分给许多读者/多个编写者方面,哪种类型的配置最佳扩展(通常我会根据给定的数据对数据进行分区)用户(或通常是您的根对象实体的任何核心实体)由单个主数据库拥有)

In terms of scaling your data persistence layer what type of configuration scales out the best in terms of partitioning your data to many readers/many writers (generally I'd partition my data based on a given user (or whatever core entity that generally is your "root" object entity) being owned by a single master DB)

推荐答案

思想我发现了一个很棒的Java集群/分布式平台,想重新打开它 -

Thought I found a great Java Clustering/Distributed platform, wanted to reopen this-

Checkout http://www.hazelcast.com

Checkout http://www.hazelcast.com

我运行测试程序,非常酷,重量很轻,使用简单。它会以对等配置自动检测群集成员。机会是无限的。

I ran the test programs, it is very cool, very light-weight and simple to use. It automatically detects the Cluster Members in a Peer-to-Peer configuration. The opportunities are limitless.

这篇关于分布式事务和/或群集中共享数据的Java解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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