Testing traffic on a webapp (Spring, Hibernate, Java) - java

I am developing a webapp and am looking into how I can automate testing of the web site such as seeing how it copes with multiple concurrent users / heavy traffic. Could anyone point me in the direction of any software or techniques I could be using to help me do this?
I am also looking into how to automate testing things at the front end? For example I have unit tested all of my business logic at the backend, but them am unsure as to what I should be do in order to automate testing of everything else.

For heavy traffic testing, I've been using JMeter. For front end testing, I'm using Selenium.

Beside Apache JMeter, which generates artificial load and allows you to test performance, there are two main technologies for testing accurately performance during operation:
Tagging Systems (like Google Analytics)
Access Log File Analysis
With tagging you create an account with Google Analytics and add some JavaScript code to the relevant places of your code, that allows the browser of your visitors to connect to GA and get captured there.
The Access log file holds all information about each session. There is a data overload, so data has to be Extracted, Transformed and Loaded (ETL) to a database. The evaluation can be then performed in nearly real-time. You can create some dashboard application that does the ETL and displays the status of you application in nearly real time.

I had same need some years ago while developing a large scale webapp.
I've been using Apache JMeter as for automation testing, and Yourkit Java Profiler for profiling Heap JVM usage and actually found lot of memory leaks!
cheers

Selenium to test the flow and expected results
Yorkit to profile CPU and Memory usage => excellent to track concurrency issues and memory leaks
Spring Insight to visually understand your application performance / load +
See the SQL executed for any page request => with drill down to the corresponding source code
Find pages which are executing slowly and drill into the cause
Verify your application's transactions are working as designed
Spring Insight is deployable as a stand alone war (Tomcat / tC Server / etc..)

Related

Are complex test scenarios with JMeter possible?

I need to run performance tests on a web application and was wondering if the following can be accomplished with Apache JMeter.
I need to simulate approximately 300 users accessing an application over a set time frame (e.g. 300 users over 10 minutes) and doing some actions, for example:
Logging in
Navigating to different pages
Inputting data
Submitting forms
I'm quite new to JMeter and performance testing in general and was wondering if this is possible? Otherwise are there any better (free) alternatives?
Many thanks.
Of course, it is possible using JMeter.
I would recommend using JMeter/ Blazemeter Chrome extension. BlazeMeter's Chrome extension let you test your application without prior scripting knowledge. It is very easy to create a test with BlazeMeter's Google Chrome extension. Here are some blogs that will help or guide you to use Chrome extension and forth.
There is another option, that is JMeter build in Test Script Recorder. Go through This thread for further detail.
Follow any one of the two procedures to record your scenario and then customize the imported script according to your requirement.
First, record your scenario using Chrome Extension.
Import the generated .jmx file to your Jmeter.
Configure the Test plan according to your requirement.
Actually this is what JMeter is designed for.
For the basics following documentation chapters are very useful:
Building a Web Test Plan
Building an Advanced Web Test Plan
When it comes to the load distribution just use separate Thread Groups to represent different groups of virtual users (like some users are logging in, another are navigating pages, etc.). If you have only one group of virtual users and several actions to simulate you can go for Throughput Controller

Using Jmeter for load testing of a standalone java application

I have to do load test for a stand alone java application. I have just one class file can i do the testing with Jmeter ? If yes then can some body throw some light over it or share any tutorial?
Actually when i went through net, i got to know that Jmeter is meant for testing web application only but i got few blogs regarding testing of stand alone application as well but they were not very much helpful.
Please help.
To load test an application you need to apply load to it. Jmeter is used to apply load to web sites by simulating users of that web site. It won't help you very much unless you are writing a web site.
For your stand alone application you will need to work out a way to simulate lots of users (usually that will involve finding or writing another program to do so) and then do that.
For example to load test a restful web service to store documents I wrote a program that looped through every file in a folder uploading them all, then downloaded the uploaded files and compared the two. We then ran that up on multiple computers simultaneously looping thousands of times through the folder. That simulated heavy load from multiple users.
Apache JMeter may be used to test performance both on static and
dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET,
etc. -, Java Objects, Data Bases and Queries, FTP Servers and more).
It can be used to simulate a heavy load on a server, group of servers,
network or object to test its strength or to analyze overall
performance under different load types. You can use it to make a
graphical analysis of performance or to test your server/script/object
behavior under heavy concurrent load.
via http://jmeter.apache.org/
so maybe it does not suite...

Play framework 2.1 application deployment

I've created my first Play application. Which is the most suitable deployment method for production? Should i copy the whole project to the production server and run play start? or should i make a war out of my application and deploy in tomcat / jboss? Which is the most recommended way? Getting confused with it comparing to its rails type of behavior. Note that this is supposed to be a big data application and also it may server loaded requests later on. So we are thinking of scalability, availability, performance aspects too. This application is decided to be deployed in a cloud.
Thanks.
As others have stated, using the dist command is the easiest way to deploy Play for a one-off application. However, to elaborate, I have here some other options and my experience with them:
When I have an app that I update frequently, I usually install Play on the server and perform updates through Git. Doing so, after every update, I simply run play stop (to stop the running server), sometimes I then run play clean to clear out any potentially corrupted libraries or binaries, then I run play stage to ensure all prerequisites are present and to perform compilation, and then finally play start to run the server for the updated app. It seems like a lot, but it is easy to automate via a quick bash script.
Another method is to deploy Play behind a front-end web server such as Apache, Nginx, etc. This is mostly useful if you want to perform some sort of load balancing, but not required as Play comes bundled with its own server. Docs: http://www.playframework.com/documentation/2.1.1/HTTPServer
Creating a WAR archive using the play2war plugin is another way to deploy, but I wouldn't recommend it unless you are giving it to someone who already has a major infrastructure built upon these servlet containers you mentioned (as many large companies do). Using a servlet containers adds a level of complexity that Play is supposed to remove by nature (hence the integrated server). There are no notable performance gains that I am aware of using this method over the two previously described.
Of course, there is always the play dist which creates the package for you, which you upload to your server and run play start from there. This is probably the easiest option. Docs: http://www.playframework.com/documentation/2.1.1/ProductionDist
For performance and scalability, the Netty server in Play will function very adequately to exceptional for what you require. Here's a reputable link showing Netty with the fastest performance of all frameworks and a "stock" Play app as coming in somewhere in the middle of the field, but way ahead of Rails/Django in terms of performance: http://www.techempower.com/blog/2013/04/05/frameworks-round-2/.
Don't forget, you can always change your deployment architecture down the road to run behind a front-end server as described above if you need more load balancing and such for availability. That is a trivial change with Play. I still would not recommend the WAR deployment option unless, like I said, you already have a large installed base of servlet containers in use that someone is forcing you to serve your app with.
Scalability and performance also has a lot more to do with other factors as well, such as your use of caching, the database configuration, use of concurrency (which Play is good at) and the quality of the underlying hardware or cloud platform. For instance, Instagram and Pinterest serve millions of people every day on a Python/Django stack which has mediocre performance by all popular benchmarks. They mitigate that with lots of caching and high-performing databases (which is usually the bottleneck in large applications).
At the risk of making this answer too long, I'll just add one last thing. I, too, used to fret over performance and scalability, thinking I needed the most powerful stack and configuration around to run my apps. That just isn't the case any more unless you're talking like Google or Facebook scale where every algorithm has to be finely tuned as it will be bombarded a billion times every day. Hardware (or cloud) resources are cheap but developer/sysadmin time isn't. You should consider ease of use and maintainability for deployment of your app over raw performance comparisons, even though in the case of Play the best performing deployment configuration is arguably the easiest option as well.
You don't need to use Play's console for running application, it consumes some resources and it's main goal is fast launch while development stage.
The best option is using dist command as described in the doc. Thanks to this, you don't even need to install Play on the target machine, as dist creates ready to use stand-alone application containing all required elements (also build-in server, so you don't need to deploy it with WAR in any container).
If you planning to use a cloud you should also check offers ie. from Heroku, or CloudBees, which allows you to deploy your application just by... pushing changes via git repository, which is very comfortable way, check the documentation's home, scroll down to links: Deploying to... for more details.

How to approach performance benchmarking of large Java application with JMX?

I'm going to performance benchmark a large Java application. What is the best approach to do it?
It is POJO-based application that consists online part with UI and WebService layer, but the most of heavy business logic is in long running batch processes implemented with Spring Batch. The application is deployed on JBoss Application Server and persists data in Oracle database.
What I'm looking to get is not only the throughput of batch process or number of concurrent requests handled by online layer. I'm also looking to get more insight and gather some internal metrics for things like batch job steps, JDBC etc. Furthermore I'm going to correlate the metrics with system-wide metrics I can get from JVM, OS, application server, database.
Ideally I'd like to do it with no code modifications if possible.
My idea to implement this kind of performance monitoring is to rely on JMX and provide a central component that can gather metrics from various MBeans and correlate them. It seems that each main component I want to measure is JMX-enabled:
JBoss Application server has extensive JMX capabilities
Spring Batch can be JMX-enabled with Spring Batch Admin extention
JVM is OK for all it's internals exposed via JMX
Oracle with DMS MEtrics also give good insight into performance of JDBC link
I was wondering if there are any good open source frameworks/tools that could help me with collection, correlation and visualization of the metrics as described above. Thanks in advance for your recommendations.
P.S. I have done my homework and browsed the open source scene with that regards, but I don'w want to put any specific names here yet to avoid biased answers.

Which FOSS Java application should be used in a performance test?

I would like to write an online book that shows people how to tune a Java web application by example. Using free tools, it will show people how to load test and monitor their apps so that they can make incremental performance improvements.
I already know that I want to use Jboss + Apache + Ubuntu. I don't really care whether I use MySQL or Postgresql. I also plan on using The Grinder to run my perf tests.
Now I just need to determine which Java application I want to test. Here are my high-level requirements:
FOSS - All of the tools in my book will be FOSS to lower the costs barrier.
It should be fairly secure - I may expose this application to the WWW, and I don't want to lose sleep over security.
Easy to deploy - I don't want people to spend too much time deploying the app.
Easy to load test - I would like a fairly simple UI that avoids too much Ajax.
DB-Backed - The app has to have a RDBMS backend.
Does anyone know of a good Java app that would meet these requirements?
Jenkins might be a good choice. Simple to deploy, and it might have some future benefit as well :)

Categories

Resources