[英]How to test if my java application can successfully handle low memory/CPU resources on Tomcat server?
I want to test how my java application would behave on Tomcat server with 512M RAM only. 我想测试我的Java应用程序在仅具有512M RAM的Tomcat服务器上的表现。 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. 我听说过APM软件,包括Stackify Prefix,New Relic APM,JMeter,JVisualVM,JVM Monitor,JBenchX-但我不确定出于我的特定目的需要继续使用其中的任何软件。
The same problem for having very limited CPU resources. 对于CPU资源非常有限的问题。 I'd like to test my app on my desktop PC before deploying to Jelastic cloud with limited memory/CPU.
我想先在台式机上测试我的应用程序,然后再部署到内存/ CPU有限的Jelastic云中。
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. 您可以通过修改
-Xmx
命令行参数来人为地限制分配给tomcat的JVM堆,该参数定义了Tomcat服务器将使用的最大堆空间。
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) 您可能还修改了CPU关联性,以将Tomcat服务器绑定到单个CPU内核(或有限数量的内核)
If you want to go further you can create a virtual machine using ie VirtualBox and replicate all the anticipated hardware/software which you'll have after the deployment. 如果您想走得更远,则可以使用VirtualBox创建虚拟机,并复制部署后将拥有的所有预期的硬件/软件。
With regards to testing I would recommend the following performance testing techniques : 关于测试,我建议以下性能测试技术 :
Using profiler tools like YourKit or JProfiler for fine-tuning your code would be beneficial as well. 使用诸如YourKit或JProfiler之类的探查器工具来微调代码也将是有益的。
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.
您可以选择自己选择的技术,但是一个简单的选择就是使用Oracle VirtualBox,它可以在许多平台上免费使用。 Just install a minimal OS inside the VM, then add Java, your application, etc. and then run your load-test against it.
只需在VM内安装一个最小的OS,然后添加Java,您的应用程序等,然后对其进行负载测试。
Networking works as usual, so you can use your existing load-testing framework and just point it at the IP address of the VM. 网络照常工作,因此您可以使用现有的负载测试框架并将其指向VM的IP地址。
There are other fancier way to do it, eg using Docker or whatever, but this will get the job done for a smoke-test. 还有其他更高级的方法,例如使用Docker或其他方法,但这可以完成烟熏测试的工作。
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). 我不建议尝试使用具有大量RAM的服务器,然后尝试在不使用虚拟机之类的情况下“合成”低RAM情况(并且BTW Docker在内部使用VM)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.