0

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!
Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
athenatechie
  • 699
  • 2
  • 8
  • 15
  • What do you expect anyone here to do about it? The issue would appear to be as suggested with the "internal workings of the API". Therefore the logical action would be to raise the issue with the maintainers directly. If this is not about an error with a "single call" but rather happens "over time" then https://github.com/softinstigate/restheart/issues would be the better place to ask. – Neil Lunn Aug 09 '17 at 23:45
  • How big is the data you are getting? you might need to increase virtual mem limit for you java app. – Serge Aug 09 '17 at 23:53
  • @Serge The data we are getting is not that large. When you are increase virtual memory increase. Are you talking about JMeter? because I am trigerring these calls directly from JMeter.( no custom API in between) – athenatechie Aug 10 '17 at 00:15
  • @Abhinav1singhal according to the stack it is be coming from mongodb.operation and it is definitely a java stack. So, it is definitely a java application (you said backend). There should be a way to increase its memory limit . Sorry, I am not familiar with these tools nor with your environment, so i cannot suggest any details, just a generic idea. – Serge Aug 10 '17 at 01:14

1 Answers1

0

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

mturatti
  • 651
  • 5
  • 10
  • We followed your instructions and it still is not able to process the request. Now, we narrowed down the issue to single REST api call but the response expected is around 14 MB in size. We will check on the heapsize and monitor it , if this is the case. Thanks. – athenatechie Aug 15 '17 at 00:57