Hazelcast vs. Ignite benchmark

前端 未结 2 896
旧时难觅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:46

    Here is the benchmark source code: https://github.com/a-rog/px100data/tree/master/examples/HazelcastVsIgnite

    It is part of the JDBC-ish NoSQL framework I mentioned earlier: Px100 Data

    Building and running it:

    cd 
    mvn clean package
    cd target
    java -cp "grid-benchmark.jar:lib/*" -Xms512m -Xmx3000m -Xss4m com.px100systems.platform.benchmark.HazelcastTest 100000
    java -cp "grid-benchmark.jar:lib/*" -Xms512m -Xmx3000m -Xss4m com.px100systems.platform.benchmark.IgniteTest 100000
    

    As you can see, I set the memory limits high to avoid garbage collection. You can also run my own framework test (see Px100DataTest.java) and compare to the two above, but let's concentrate on pure performance. Neither test uses Spring or anything else except for Hazelcast 3.5.1 and Ignite 1.3.3 - the latest at the moment.

    The benchmark transactionally inserts the specified number of appr. 1K-size records (100000 of them - you can increase it, but beware of memory) in batches (transactions) of 1000. Then it executes two queries with ascending and descending sort: four total. All query fields and ORDER BY are indexed.

    I am not going to post the entire class (download it from GitHub). The Hazelcast query looks like this:

    PagingPredicate predicate = new PagingPredicate(
            new Predicates.AndPredicate(new Predicates.LikePredicate("textField", "%Jane%"),
                new Predicates.GreaterLessPredicate("id", first.getId(), false, false)),
            (o1, o2) -> ((TestEntity)o1.getValue()).getId().compareTo(((TestEntity)o2.getValue()).getId()),
            100);
    

    The matching Ignite query:

    SqlQuery query = new SqlQuery<>(TestEntity.class,
            "FROM TestEntity WHERE textField LIKE '%Jane%' AND id > '" + first.getId() + "' ORDER BY id LIMIT 100");
        query.setPageSize(100);
    

    Here are the results executed on my 2012 8-core MBP with 8G of memory:

    Hazelcast

    Starting - used heap: 49791048 bytes
    Inserting 100000 records: ....................................................................................................
    Inserted all records - used heap: 580885264 bytes
    Map: 100000 entries, used heap: 531094216 bytes, inserts took 5458 ms
    Query 1 count: 100, time: 344 ms, heap size: 298844824 bytes
    Query 2 count: 100, time: 115 ms, heap size: 454902648 bytes
    Query 3 count: 100, time: 165 ms, heap size: 657153784 bytes
    Query 4 count: 100, time: 106 ms, heap size: 811155544 bytes
    

    Ignite

    Starting - used heap: 100261632 bytes
    Inserting 100000 records: ....................................................................................................
    Inserted all records - used heap: 1241999968 bytes
    Cache: 100000 entries, heap size: 1141738336 bytes, inserts took 14387 ms
    Query 1 count: 100, time: 222 ms, heap size: 917907456 bytes
    Query 2 count: 100, time: 128 ms, heap size: 926325264 bytes
    Query 3 count: 100, time: 7 ms, heap size: 926325264 bytes
    Query 4 count: 100, time: 103 ms, heap size: 934743064 bytes 
    

    One obvious difference is the insert performance - noticeable in real life. However very rarely one inserts a 1000 records. Typically it is one insert or update (saving entered user's data, etc.), so it doesn't bother me. However the query performance does. Most data-centric business software is read-heavy.

    Note the memory consumption. Ignite is much more RAM-hungry than Hazelcast. Which can explain better query performance. Well, if I decided to use an in-memory grid, should I worry about the memory?

    You can clearly tell when data grids hit indexes and when they don't, how they cache compiled queries (the 7ms one), etc. I don't want to speculate and will let you play with it, as well, as Hazelcast and Ignite developers provide some insight.

    As far, as general performance, it is comparable, if not below MySQL. IMO in-memory technology should do better. I am sure both companies will take notes.

    The results above are pretty close. However when used within Px100 Data and the higher level Px100 (which heavily relies on indexed "sort fields" for pagination) Ignite pulls ahead and is better suited for my framework. I care primarily about the query performance.

提交回复
热议问题