0

I want to test how my java application would behave on Tomcat server with 512M RAM only. In other words I need to do memory load-testing to check if my application can run in such restricted environment.

Using which tools and how can I achieve this?

I heard about APM software including Stackify Prefix, New Relic APM, JMeter, JVisualVM, JVM Monitor, JBenchX - but I am not sure I need to proceed with any of them for my specific purpose.

The same problem for having very limited CPU resources. I'd like to test my app on my desktop PC before deploying to Jelastic cloud with limited memory/CPU.

caasdads
  • 409
  • 4
  • 12
  • 512M is not much. I'd look for a better hosting provider, to be honest. I think Amazon will give you four times that for $15 a month. But I think your best bet right now is to set your JVM to those memory limits, run a real instance on your PC, and run a large functional test for at least 4 to 8 hours, and 24 is better, to make sure you can handle a large load. – markspace Nov 29 '18 at 18:07

2 Answers2

1

You can artificially limit the JVM heap allocated to tomcat by modifying -Xmx command-line argument which defines the maximum heap space your Tomcat server will use.

If low heap size is the only thing you would like to test - it would be sufficient.

You might also amending CPU affinity to bind your Tomcat server to a single CPU core (or limited number of cores)


If you want to go further you can create a virtual machine using i.e. VirtualBox and replicate all the anticipated hardware/software which you'll have after the deployment.

With regards to testing I would recommend the following performance testing techniques:

  • Load Testing - putting your system under anticipated load to see if it is capable of handling it
  • Soak Testing - basically the same as Load Testing but for prolonged duration (i.e. overnight or weekend) - it will allow you to identify memory leaks
  • Stress Testing - start with Load Testing and gradually increase the load until response time starts exceeding acceptable threshold or errors start occurring (whatever comes the first) - it will let you know the limits of your application/configuration and vision what and how is gonna break

Using profiler tools like YourKit or JProfiler for fine-tuning your code would be beneficial as well.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • This isn't great advice, because there is a big difference between 512M of *jada heap space* 512M of *total system RAM*. Remember that the OS has to fit into that 512M of system RAM, too, and that the Java Virtual Machine uses a bunch of non-heap-memory as well. – Christopher Schultz Nov 30 '18 at 17:23
  • Did I mention 512Mb of heap anywhere? – Dmitri T Nov 30 '18 at 17:35
  • No, but the original poster specifically requested it. You mentioned using `-Xmx` which restricts the heap *only*. You could replace `512M` in my comment with any value, and it would still not be valid as a way to restrict the JVM to a limited amount of total memory (not just heap memory). – Christopher Schultz Nov 30 '18 at 17:42
0

The best way to do this is with a Virtual Machine. You can pick your technology of choice, but an easy option would be to use Oracle VirtualBox, which is freely-available for many platforms. Just install a minimal OS inside the VM, then add Java, your application, etc. and then run your load-test against it.

Networking works as usual, so you can use your existing load-testing framework and just point it at the IP address of the VM.

There are other fancier way to do it, e.g. using Docker or whatever, but this will get the job done for a smoke-test.

I wouldn't recommend trying to use a server with a large amount of RAM and then try to "synthesize" a low-RAM situation without using something like a Virtual Machine (and BTW Docker uses VMs internally).

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77