we implemented RESTHEART to get aggregated data from MongoDB. For single requests , the data is coming up fine and meets the requirement. When we started checking this under JMeter requests by adding load on MongoDB we got exceptions at backend. We shared these exceptions with MongoDB engineers and they are indicating it could be because of restheart api issue. Has anyone faced these issues before?
@Andrea Di Cesare , any help on this will be greatly appreciated.
Below is detail Below are the examples URI which error out with “Out of memory”. REST API CALLS http://ftc-lbeapoc202:8080/statdata/InsStatData/_aggrs/getStatDataByIssuerIdSectionName?avars={'issuerId':66915,'sectionName':'SCDPT1'} http://ftc-lbeapoc202:8080/statdata/InsStatData/_aggrs/getStatDataByIssuerIdSectionName?avars={'issuerId':66915,'sectionName':'SCDPT1','year':2014}
Error in server log:
[[1;31mERROR^[[0;39m org.restheart.handlers.ErrorHandler - Error handling
the request
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3554)
at java.util.Arrays.copyOf(Arrays.java:3525)
at java.util.ArrayList.grow(ArrayList.java:272)
at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:246)
at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:238)
at java.util.ArrayList.add(ArrayList.java:469)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:53)
at org.bson.codecs
Error in response:
{
· _exceptions:
[
o {
§ exception: "java.lang.OutOfMemoryError",
§ exception message: "Java heap space"
}
],
· http status code: 500,
· http status description: "Internal Server Error",
· message: "Error handling the request, see log for more
information"
}
Thanks!
RESTHeart is a plain Java application and what you see is a java.lang.OutOfMemoryError
exception. It means your tests are using all the available JVM's heap space, so the JVM is going out of memory.
By default:
Java 8 takes Larger of 1/6th of your physical memory for your
-Xms<size>
(Minimum HeapSize) and Smaller of 1/4th of your physical memory for your-Xmx<size>
(Maximum HeapSize).
In Linux or Mac OS systems you can check your default Heap size with:
java -XX:+PrintFlagsFinal -version | grep -iE HeapSize
If your server has enough available physical memory, you can try running RESTHeart with a bigger heap, adding the -Xmn<size>
parameter to the command line.
For example: java -Xmx3072m
will set the JVM's maximum heap size to 3GB.
Rif: https://docs.oracle.com/cd/E15523_01/web.1111/e13814/jvm_tuning.htm#PERFM164