Hazelcast vs. Ignite benchmark

前端 未结 2 887
旧时难觅i
旧时难觅i 2021-02-13 04:08

I am using data grids as my primary \"database\". I noticed a drastic difference between Hazelcast and Ignite query performance. I optimized my data grid usage by the proper cus

2条回答
  •  失恋的感觉
    2021-02-13 04:26

    I have reviewed the provided code on GitHub and have many comments:

    Indexing and Joins

    1. Probably the most important point is that Apache Ignite indexing is a lot more sophisticated than Hazelcast. Unlike Hazelcast, Ignite supports ANSI 99 SQL, so you can write your queries at will.
    2. Most importantly, unlike Hazelcast, Ignite supports group-indexes and SQL JOINs across different caches or data types. Imagine that you have Person and Organization tables, and you need to select all Persons working for the same Organization. This would be impossible to do in 1 step in Hazelcast (correct me if I am wrong), but in Ignite it is a simple SQL JOIN query.

    Given the above, Ignite indexes will take a bit longer to create, especially in your test, where you have 7 of them.

    Fixes in TestEntity Class

    In your code, the entity you store in cache, TestEntity, recalculates the value for idSort, createdAtSort, and modifiedAtSort every time the getter is called. Ignite calls these getters several times while the entity is being stored in the index tree. A simple fix to the TestEntity class provides 4x performance improvement: https://gist.github.com/dsetrakyan/6bfe089d53f888448503

    Heap Measurement is Not Accurate

    The way you measure heap is incorrect. You should at least call System.gc() before taking the heap measurement, and even that would not be accurate. For example, in the results below, I get negative heap size using your method.

    Warmup

    Every benchmark requires a warm-up. For example, when I apply the TestEntity fix, as suggested above, and do the cache population and queries 2 times, I get better results.

    MySQL Comparison

    I don't think comparing a single-node Data Grid test to MySQL is fair, neither for Ignite, nor for Hazelcast. Databases have their own caching and whenever working with such small memory sizes, you are usually testing database in-memory cache vs. Data Grid in-memory cache.

    The performance benefit usually comes in whenever doing a distributed test over a partitioned cache. This way a Data Grid will execute the query on each cluster node in parallel and the results should come back a lot faster.

    Results

    Here are the results I got for Apache Ignite. They look a lot better after I made the aforementioned fixes.

    Note that the 2nd time we execute the cache population and cache queries, we get better results because the HotSpot JVM is warmed up.

    It is worth mentioning that Ignite does not cache query results. Every time you run the query, you are executing it from scratch.

    [00:45:15] Ignite node started OK (id=0960e091, grid=Benchmark)
    [00:45:15] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=8.0GB]
    Starting - used heap: 225847216 bytes
    Inserting 100000 records: ....................................................................................................
    Inserted all records - used heap: 1001824120 bytes
    Cache: 100000 entries, heap size: 775976904 bytes, inserts took 14819 ms
    ------------------------------------
    Starting - used heap: 1139467848 bytes
    Inserting 100000 records: ....................................................................................................
    Inserted all records - used heap: 978473664 bytes
    Cache: 100000 entries, heap size: **-160994184** bytes, inserts took 11082 ms
    ------------------------------------
    Query 1 count: 100, time: 110 ms, heap size: 1037116472 bytes
    Query 2 count: 100, time: 285 ms, heap size: 1037116472 bytes
    Query 3 count: 100, time: 19 ms, heap size: 1037116472 bytes
    Query 4 count: 100, time: 123 ms, heap size: 1037116472 bytes
    ------------------------------------
    Query 1 count: 100, time: 10 ms, heap size: 1037116472 bytes
    Query 2 count: 100, time: 116 ms, heap size: 1056692952 bytes
    Query 3 count: 100, time: 6 ms, heap size: 1056692952 bytes
    Query 4 count: 100, time: 119 ms, heap size: 1056692952 bytes
    ------------------------------------
    [00:45:52] Ignite node stopped OK [uptime=00:00:36:515]
    

    I will create another GitHub repo with the corrected code and post it here when I am more awake (coffee is not helping anymore).

提交回复
热议问题