简体   繁体   English

如何测试我的Java应用程序是否可以成功处理Tomcat服务器上的低内存/ CPU资源?

[英]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 : 关于测试,我建议以下性能测试技术

  • 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 (ie 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. 使用诸如YourKitJProfiler之类的探查器工具来微调代码也将是有益的。

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.

相关问题 低内存Java应用程序服务器 - Low memory Java application server 我如何在NetBeans中通过tomcat运行的Java Web应用程序中测量CPU和内存 - How can I measure CPU and Memory in java web application run through tomcat in netbeans 如何以编程方式从我的Java应用程序中获取内存,线程和CPU用法? - How can I programmatically get memory, thread and CPU usuage from within my Java application? 由于Java堆内存不足,Tomcat不会部署应用程序 - Tomcat won't deploy an application due low java heap memory 如何为嵌入在我的 spring-boot 应用程序中的 Web 服务器(Tomcat)配置低级套接字属性? - How to configure low-level socket properties for a web server (Tomcat) embedded in my spring-boot application? Java API,用于获取我的java应用程序的CPU和内存使用情况 - Java API to get CPU and memory usage of my java application 如何测试我的Web应用程序可以处理“100个用户”? - how to test that my web application can handle “100 users”? 无法从 Tomcat 服务器访问 Java 资源文件夹中的文件 - Can't access file in Java resources folder from Tomcat server Tomcat服务器中的Java 8 Web应用程序内存泄漏问题 - Java 8 web application memory leak issue in Tomcat server 在Java J2EE服务器上平衡CPU /内存资源的线程使用 - Balancing thread usage of CPU/memory resources on Java J2EE server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM