Hazelcast IMDG 4.2.0 performance latency issue

226 views
Skip to first unread message

Bhavesh Jain

unread,
Jul 22, 2021, 2:38:03 AM7/22/21
to Hazelcast
We are using hazelcast IMDG 4.2.0 with client server mode to read cached data from DB.
Our application was undergone heavy performance testing and we found that with hazelcast calls were causing latency issues.

1) We initially used hazelcast SQL module to query map with criteria and that was too slow even when number of entries in hazelcast map were less than 5000.
2) We even considered fetching data directly from map and iterate through it, it helped to improve performance slightly  but still it was not upto the mark.

Also we observed that hazelcast client threads were consuming 40% of cpu whenever they were active.

As this is a performance env we are using a 4 core machine with one hazelcast member with default configurations. Also Hazelcast client is using Near cache configuration.

Please suggest if there is any way we can improve on performance with certain configuration changes.



Neil Stevenson

unread,
Jul 22, 2021, 3:00:26 AM7/22/21
to Hazelcast
4 cores isn't much.  Here (https://hazelcast.com/resources/hazelcast-deployment-operations-guide/) , section 9.1.4 - "we recommend a minimum of 8 cores"

How is your data model configured for Serialization ?

That's a frequent point for optimization

N

Bhavesh Jain

unread,
Jul 22, 2021, 6:30:55 AM7/22/21
to Hazelcast
Thanks !!
We will try with a machine which has more than 8 cores.
We are using java's default serialization, do you recommend to use any other serialization?

Neil Stevenson

unread,
Jul 22, 2021, 6:39:49 AM7/22/21
to Hazelcast
Java serialisation is usually worst by a long way, see https://hazelcast.com/blog/comparing-serialization-options/

However if the near-cache is correctly configured then serialization need not occur, so it's worth checking this also

Bhavesh Jain

unread,
Jul 23, 2021, 2:55:49 AM7/23/21
to Hazelcast
Thanks Neil for your valuable input !!
Can you please refer me to some example where HazelcastJsonValue is used for serialization?

Neil Stevenson

unread,
Jul 23, 2021, 3:20:50 AM7/23/21
to Hazelcast
JSON is pretty easy to use. You just form it as a String  and use it in the HazelcastJsonValue constructor,  and serialization is handled for you

String s =. " { \"firstName\" : \"Neil\" }";
HazelcastJsonValue v = new HazelcastJsonValue(s);



Neil

Bhavesh Jain

unread,
Jul 23, 2021, 10:25:26 AM7/23/21
to Hazelcast
Hi Neil,

I tried using HazelcastJson value and I could perform put and get into Map.
But when I try to execute Hazelcast SQL service to retrieve data from Map, I am getting below error.
It seems hazelcast member is not able to deserialize json at its end.

How can I provide config at hazelcast member configuration xml to use HazelcastJsonValue Serialization ?

Exception in thread "main" com.hazelcast.sql.HazelcastSqlException: Failed to resolve value metadata: JSON objects are not supported.
at com.hazelcast.sql.impl.client.SqlClientService.handleResponseError(SqlClientService.java:264)
at com.hazelcast.sql.impl.client.SqlClientService.handleExecuteResponse(SqlClientService.java:133)
at com.hazelcast.sql.impl.client.SqlClientService.lambda$execute$0(SqlClientService.java:111)
at com.hazelcast.internal.util.ExceptionUtil.lambda$withTryCatch$1(ExceptionUtil.java:207)
at com.hazelcast.client.impl.spi.impl.ClientInvocationFuture$CallIdTrackingBiConsumer.accept(ClientInvocationFuture.java:268)
at com.hazelcast.spi.impl.AbstractInvocationFuture$WhenCompleteNode.lambda$execute$0(AbstractInvocationFuture.java:1563)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Thanks
Bhavesh

Neil Stevenson

unread,
Jul 23, 2021, 11:37:10 AM7/23/21
to Hazelcast
You can query JSON, but you will need to define how the JSON objects appear to the SQL engine,

Something like this pseudo-code:

CREATE MAPPING mapname

(

id           VARCHAR, 

createdDate BIGINT 

 ) 

TYPE IMap

OPTIONS (

  'keyFormat' = 'java',

  'keyJavaClass' = 'java.lang.String',

  'valueFormat' = 'json'

)

And you'll need the "hazelcast-sql" module on the classpath

Docs are here https://docs.hazelcast.com/hazelcast/5.0-beta-1/query/sql-overview.html . That's the 5.0 version,. which is still a BETA, but fine for evaluation, not for production until the official release.

Reply all
Reply to author
Forward
0 new messages