In this second part, I test the Apache Ignite SQL API. This is really useful when we need to work with a tables structure in memory.
Apache Ignite SQL API is ANSI-99 compliant. This means that we can perform all operations from this specification.
Check this link to know more about ANSI-99 specification.
This test created a fictitious Orders and executed INSERT and SELECT statements to check the performance from Apache Ignite SQL API.
The sections below will give more details about that.
For this test, I used the machine settings below:
- Windows 10
- Intel(R) Core(TM) i5–4440
- 16 GB RAM
- .NET 5
- Apache Ignite 2.10.0
- Docker version 20.10.6
Run docker container
Before implementing our repository, let’s run Apache Ignite with its official Docker container.
Then, run the following command to start the Apache Ignite container:
We can persist the data that will be used in the sections below in memory or on disk. For this article, the is being persisted in memory.
After running the command above, you should see the screen below:
Check if there are error messages when the Apache Ignite container has been started. If everything is OK, let’s test its Cache feature in the sections below.
Basic Settings for .NET and Apache Ignite
The steps to use Apache Ignite are very simple. You can follow the items below to allow your application to connect with Apache Ignite.
- Add NuGet package below:
Install-Package Apache.Ignite -Version 2.10.0
- Set up a new connection with IgniteClientConfiguration class. In this part you need to provide at least one Apache Ignite server:
- Start a new connection with Ignition.StartClient method. This method returns an interface called IIgniteClient, which contains methods to work with cache clusters:
- With IIgniteClient.GetOrCreateCache, get or create a new cache repository to a specific object type. I created two repositories
Done! Now your application can perform operations in a repository from Apache Ignite. I recommend checking the Apache Ignite documentation to know more about available methods.
Testing the SQL API Feature
Apache Ignite uses the cache repository to store the table’s data. Then, we can create repositories that will contain two tables: OrderTest and OrderItemTest.
The next step before populating our repositories is define tables structure:
As we noted, to send instructions to Apache Ignite, we need to call the method ICacheClient.Query. This method will receive our SQL statement through SqlFieldsQuery class instance.
Basically, one OrderTest has one or more OrderItemTest associated with it. The code below inserts 1 million orders in OrderTest table, and for each order, 10 order items are inserted in OrderItemTest table.
As an attempt to create a small “workload” against the Apache Ignite container, those operations are executed with Parallel Task.
As we can see in the code above, some KPIs were created to check the performance of each operation against Apache Ignite Cache:
KPIs Operation Time:
- INPUT time (AVG seconds): the average in seconds to add an order to OrderTest table, and its items to OrderItemTest table.
- OUTPUT time (AVG seconds): the average in seconds to get an order from OrderTest table, and its items OrderItemTest table.
- INPUT time (MAX seconds): the maximum time in seconds to add an order to OrderTest table, and its items to OrderItemTest table.
- OUTPUT time (MAX seconds): the maximum time in seconds to get an order from OrderTest table, and its items OrderItemTest table.
- INPUT time (MIN seconds): the minimum time in seconds to to add an order to OrderTest table, and its items to OrderItemTest table.
- OUTPUT time (MIN seconds): the minimum time in seconds to get an order from OrderTest table, and its items OrderItemTest table.
- INPUT ERROR: number of exceptions created when the application was adding an order and its items to tables.
- OUTPUT ERROR: number of exceptions created when the application was getting an order and its items from those tables.
- ITEMS CREATED: how many orders were created.
- ITEMS RECEIVED: how many orders were got from the table.
- ITEMS MISSING: how many orders were not in the table.
Results from Application Test
After running the application test, the metrics below were collected:
In general, the Apache Ignite presented a nice performance adding and getting orders and its items. The average time to add orders was 0.0882 seconds and 0.056 seconds to get those items from the table. Also, there were no exceptions and lost items in this test.
Checking the Apache Ignite container, the memory consumption increased a lot. from 355 MB to 2,6 GB:
- Container stats (initial state)
- Container stats (after running application test)
As I mentioned in the article before, from a development perspective, I think that this feature from Apache Ignite is the most interesting so far.
However, the memory consumption was higher than add objects in the Cache System.
You can check the first part of this article here: .NET and Apache Ignite: Testing Cache and SQL API features — Part I
I hope that this can be helpful for you!
I am a Software Engineer that loves thinking about Systems Integrations and Cloud-Native Applications