Java 中最高性能的数据库

发布于 2024-07-11 09:08:20 字数 234 浏览 5 评论 0原文

我需要用 Java 实现(真正)高性能内存数据库/存储机制的想法。 在存储20,000+ java对象的范围内,每5秒左右更新一次。
我愿意接受的一些选项:

纯 JDBC/数据库组合

JDO

JPA/ORM/数据库组合

对象数据库

其他存储机制

我最好的选择是什么? 你有什么经历?

编辑:我还需要能够查询这些对象

I need ideas to implement a (really) high performance in-memory Database/Storage Mechanism in Java. In the range of storing 20,000+ java objects, updated every 5 or so seconds.
Some options I am open to:

Pure JDBC/database combination

JDO

JPA/ORM/database combination

An Object Database

Other Storage Mechanisms

What is my best option? What are your experiences?

EDIT: I also need like to be able to Query these objects

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

喵星人汪星人 2024-07-18 09:08:20

您可以尝试类似 Prevayler (基本上是一个内存缓存,可以为您处理序列化和备份,以便数据持久存在并且事务安全)。 还有其他类似的项目。
我已经在一个大型项目中使用过它,它安全且速度非常快。

如果是同一组 20,000 个对象,或者至少不是每 5 秒 20,000 个新对象,但有大量更改,那么您最好缓存更改并定期以批处理模式写入更改(jdbc 批处理更新比单独行快得多)更新)。 取决于您是否需要以事务方式包装每个写入,以及您是否需要更改日志的记录或仅聚合更改。

编辑:正如其他帖子提到的 Prevayler 我想我应该就它的作用留下注释:
基本上,您创建一个可搜索/可序列化的对象(通常是某种 Map),该对象包装在 Prevayler 实例中,并序列化到磁盘。 您不是直接对地图进行更改,而是通过向 Prevayler 实例发送更改的可序列化记录(只是一个包含更改指令的对象)来进行更改。 Prevayler 的事务版本是将序列化更改写入磁盘,以便在发生故障时它可以加载最后的完整备份,然后根据该备份重放更改。 它是安全的,尽管您必须有足够的内存来加载所有数据,而且它是一个相当旧的 API,因此不幸的是没有通用接口。 但绝对稳定并且可以像宣传的那样工作。

You could try something like Prevayler (basically an in-memory cache that handles serialization and backup for you so data persists and is transactionally safe). There are other similar projects.
I've used it for a large project, it's safe and extremely fast.

If it's the same set of 20,000 objects, or at least not 20,000 new objects every 5 seconds but lots of changes, you might be better off cacheing the changes and periodically writing the changes in batch mode (jdbc batch updates are much faster than individual row updates). Depends on whether you need each write to be transactionally wrapped, and whether you'll need a record of the change logs or just aggregate changes.

Edit: as other posts have mentioned Prevayler I thought I'd leave a note on what it does:
Basically you create a searchable/serializable object (typically a Map of some sort) which is wrapped in a Prevayler instance, which is serialized to disk. Rather than making changes directly to your map, you make changes by sending your Prevayler instance a serializable record of your change (just an object that contains the change instruction). Prevayler's version of a transaction is to write your serialization changes to disk so that in the event of failure it can load the last complete backup and then replay the changes against that. It's safe, although you do have to have enough memory to load all of your data, and it's a fairly old API, so no generic interfaces, unfortunately. But definitely stable and works as advertised.

夏有森光若流苏 2024-07-18 09:08:20

我强烈推荐H2。 这是 HSQLDB 的“第二代”版本,由原作者之一完成。 H2 允许我们对 DAO 层进行单元测试,而无需实际的 PostgreSQL 数据库,这太棒了

有一个活跃的网络组和邮件列表,作者 Thomas Mueller 对查询非常敏感(哈哈,有点双关语。)

I highly recommend H2. This is a kind of "second generation" version of HSQLDB done by one of the original authors. H2 allows us to unit-test our DAO layer without requiring an actual PostgreSQL database, which is awesome.

There is an active net group and mailing list, and the author Thomas Mueller is very responsive to queries (hah, little pun there.)

£噩梦荏苒 2024-07-18 09:08:20

我不知道这是否是最快的选择,但我对 H2 每当我使用它时。 它是由最初编写 Hypersonic(后来成为 HSQLDB)的同一个人编写的。

据称速度非常快的另一个选项是 Prevayler

I don't know if it is the fastest option, but I've been very satisfied with H2 whenever I've used it. It's written by the same person who originally wrote Hypersonic (which later became HSQLDB).

Another option that is allegedly very fast is Prevayler.

邮友 2024-07-18 09:08:20

这是一个有点老的问题,但现在有很多数据库的性能水平达到 20,000/s。 选择哪个数据库取决于数据结构和您想要进行的查询类型。 它还取决于总体积。

我们在处理大量时间序列数据时遇到了类似的问题,大约 300,000 条记录/秒,我们最终编写了一个新的数据库,具有足够简单的 API 和不错的性能。 它每秒可以执行大约 2,000,000 次对象写入,并且我们没有使用 ORM。

后来它演变成 QuestDB

It is a bit of an old question, but these days there is a whole lot of databases that have a level of performance of 20,000/s. Which database to chose depends on data structure and type of queries you'd like to be making. It also depends on overall volume.

We had similar problem with large volume of time series data, about 300,000 rec/s and we ended up writing a new database, with simple enough API and decent performance. It can do about 2,000,000 object writes/s and we did away without ORM.

It later evolved into QuestDB.

比忠 2024-07-18 09:08:20

尝试以下方法,它在 Hibernate 和其他 ORM 框架中表现得非常好

http://hsqldb.org/

Try the following, it performs really well with Hibernate and other ORM frameworks

http://hsqldb.org/

千仐 2024-07-18 09:08:20

Chronicle Map 是一个可嵌入的纯 Java 持久数据库,提供简单的 java.util。地图接口。 它每秒可承受来自单个线程的约100万次查询/更新,具有一致的读/写性能,并且几乎与机器中的内核数量线性扩展。

以下是一些最近的性能研究与实际数据:

Chronicle Map is an embeddable pure Java persistent database, providing a simple java.util.Map interface. It withstands about 1 million queries/updates per second from a single thread, consistent read/write performance and scales almost linearly to the number of cores in the machine.

Here are some recent performance research with actual numbers:

思慕 2024-07-18 09:08:20

我会尝试OrientDB

I would give a try to OrientDB.

挽清梦 2024-07-18 09:08:20

兵马俑也可能是您的答案。 它允许多个虚拟机共享对象,以便您可以分配负载等...

Terracotta might also be an answer for you. It allows multiple VMs to share objects so you can distribute load etc...

深海里的那抹蓝 2024-07-18 09:08:20

您还可以查看 db4o

You can also check out db4o

み青杉依旧 2024-07-18 09:08:20

Berkeley DB for Java 是一个快速的内存数据库,非常快对于简单的对象图很有用。

Berkeley DB for Java is a fast in memory database, extremely useful for simple object graphs.

煮酒 2024-07-18 09:08:20

hsqldb 相当快,但它不是 ACID 事务安全的。 我知道的最快的 java 数据库是 db4o:基准测试

编辑:请注意 Prevayler 不是数据库,请参阅 http ://www.prevayler.org/wiki.jsp?topic=PrevaylerIsNotADatabase。 如果你的内存不足,那你就不走运了。

hsqldb is quite fast, but it is not ACID transaction-safe. The fastest java-database I know is db4o: benchmarks.

Edit: Please notice that Prevayler is not a database, see http://www.prevayler.org/wiki.jsp?topic=PrevaylerIsNotADatabase. If you're out of RAM, you're out of luck.

橙味迷妹 2024-07-18 09:08:20

H2 确实太棒了,事实上,在内存、普通服务器和事务方面,你拥有一切。 然而,它在性能上无法与对象数据库相比,我看到提到了 Db4o,事实上,我使用 Neodatis 获得了更好的性能,并且 Maven 存储库中的所有内容都设置得很好。 虽然不是很坚固,像法拉利一样快,但不像甲骨文那样的卡车。

H2 is truly fantastic, indeed, in memory, normal server and transactional, you have it all. However It doesn't compare in performance to the object databases, I see Db4o mentioned, I have had much better performance with Neodatis in fact, and everything nicely set up in Maven repositories. Although not very robust, like a Ferrari, fast but not a truck like Oracle.

最舍不得你 2024-07-18 09:08:20

如果您想将所有数据存储在内存中,您可能需要查看 Prevayler

我自己从未使用过它,但对于所有数据都可以存储在内存中的情况,它似乎是比使用关系数据库更好的解决方案。

If you want to store all of your data in memory, you might want to look at Prevayler.

I've never used it myself, but it seems like a much better solution than using a relational database for those cases in which all of your data can be stored in memory.

喜你已久 2024-07-18 09:08:20

您可以尝试 CSQL (在开源版和企业版下可用)它比基于磁盘的数据库系统提供 30 倍的性能改进,并且提供 JDBC 接口。 它可以配置为独立的主内存数据库或作为 MySQL、Postgres、Oracle 数据库的透明缓存。

You can try CSQL (available under open source and enterprise version) It provides 30X performance improvement over disk based database systems and provides JDBC interface. It can be configured to work as stand alone main memory database or as a transparent cache to MySQL, Postgres, Oracle databases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文