Putting Spring Web Flow to a Load Test |
|

Load testing a Web Flow application is similar to load testing any other web application – we'll use a load testing tool to simulate increasing levels of concurrent client access in order to capture essential performance statistics.
With Web Flow there will be a couple of important considerations for the load test:
- The load test must maintain independent “cookie storage area� so each client request can carry an independent HTTP session.
- We need a mechanism for extracting the unique flow execution key from the initial response and use it to customize subsequent requests in the same flow session.
Apache JMeter is an open-source performance test tool that can satisfy both considerations.
For 1) we add an HTTP Cookie Manager element at the root of each Test Group exercising Web Flow functionality. The Cookie Manager ensures each simulated client request can have its own cookies independent of other client requests thus allowing the servlet container to track independent HTTP sessions through the jsessionid cookie.
For 2) we add a Regular Expression Extractor immediately after the HTTP Request Element that initiates the flow. The purpose of the Extractor is to parse the HTTP response, locate some text using a regular expression we provide, and to make that text available as a variable for subsequent HTTP Request elements to use. Here is a sample Regular Expression Extractor configuration:
Reference Name: flowExecutionKey
Regular Expression: name="_flowExecutionKey" value="(.*)"
Template: $1$
Match No.: 0
With the above configuration, we can now embed the variable ${flowExecutionKey}in subsequent HTTP Request Elements that are part of the same flow session.
Now let's use this to put Web Flow to a load test. To properly exercise representative Web Flow functionality I created a sample web flow application to mimic a 6-step shopping cart flow collecting user input for shipping address, shipping options, credit card, billing address, order confirmation, as well as an order summary at the end. Individual steps in this flow include data binding and validation, view states, action states, decision states, and sub-flow states – things we'd expect to find in a typical Web Flow application. The application however uses stubs instead of actual database access code to avoid including such numbers in the overall statistics. We'd like to focus on Web Flow alone for this test.
After building the application and creating the JMeter scripts I added an Aggregate Report element to record performance stats for tests with different load levels.
Using my Lenovo T60 dual-core laptop running Ubuntu and Apache Tomcat version 5.5 as the servlet container configured for a maximum of 150 concurrent connections I observed the following results:
| Users | 90% | Max | Requests/sec | KB/sec | Total Requests |
| 20 | 102 | 596 | 351 | 380 | 18000 |
| 60 | 372 | 5942 | 338 | 366 | 18000 |
| 80 | 463 | 10287 | 336 | 364 | 18000 |
| 100 | 550 | 11144 | 315 | 342 | 18000 |
| 150 | 687 | 20691 | 306 | 332 | 18000 |
Real load testing should be done on real hardware and based on real use cases. There is no substitute for that. However, we can derive certain conclusions from the above numbers.
The above numbers indicate that when exercising core Web Flow functionality throughput remains stable even as the number of concurrent users is significantly increased. The response time for 90% of users remains less than a second. The worst response time climbs as the load increases but that's not surprising considering the inadequate hardware used for testing.
Using the above technique you can load test your own Web Flow applications.
Similar Posts
- Spring Framework 3.2 RC1: Spring MVC Test Framework
- Spring Web Flow 2.0 M4 – Feedback Requested
- Spring MVC 3.2 Preview: Techniques for Real-time Updates
- Introducing tc Server Developer Edition – with Spring Insight
- Spring Web Flow 2.2.0.M1 Released





david says:
Added on July 3rd, 2007 at 9:50 amHi Rossen,
Any chance you could give a screen shot of your Test Plan in the JMeter GUI, I would like to see exactly where you place the Regular Expression Extractor and HTTP Cookie Manager in relation to the other elements.
Thanks for the article though, I know a couple people who were trying similar things.
Rossen Stoyanchev (blog author) says:
Added on July 10th, 2007 at 4:21 amHi David, I've attached a screenshot as well as the content of the JMeter settings file to the message above.
morten says:
Added on November 1st, 2007 at 2:36 pmAny idead why I get
"
morten says:
Added on November 1st, 2007 at 2:40 pm(Sorry, put my previous post seemed to fail).
Any idea why I get "Exception:Badly formatted flow execution key '${flowExecutionKey}'" when I use a ${flowExecutionKey} in a subsequent HTTP Request Element (a POST request)?
Tristan says:
Added on November 9th, 2007 at 9:41 amI get the same badly formatted flow exception key
Rossen Stoyanchev (blog author) says:
Added on November 9th, 2007 at 3:09 pmTake a look at the attached screenshot and compare that to your settings.
The Regular Expression Extractor I have (called \"Flow Execution Key Extractor\") is a child of an HTTP Sampler (called SimpleController) and is located immediately after the first request that comes back with a flowExecutionKey. As per the JMeter documentation:
\"A Regular Expression Extractor will execute after each Sample request in its scope, applying the regular expression, extracting the requested values, generate the template string, and store the result into the given variable name\"
Beyond that there are several potential issues you might be having:
1) Are you placing the Regular Expression Extractor for the flow execution key after a request that contains what the regular expression is looking for?
2) Ensure you JSP page contains what the regular expression is looking for. In other words you must have a hidden variable such as \". If not you will need to adjust the regular expression to match your page.
3) Use a \"Save Response\" post processor to save the HTML returned from JMeter and check it contains what the regular expression is trying to match on.
Good luck.
John Dondapati says:
Added on November 25th, 2008 at 11:53 amHi Rossen,
Thanks for the detailed post. I was wondering if it is possible to load test Spring Web flow with LoadRunner. Abit of googling suggests that not many people are successful in doing so.
Is it possible for you to shed any light on this? Thanks!
sanjeev says:
Added on January 28th, 2010 at 7:43 amHi,
I have user spring webflow2.0. I want to load test using jmeter.
The setting provided in the document does not work for me. Is the setting different for spring webflow 2.0. The url looks as follows. It does not has flowexecutionKey
http://localhost:8080/contextroot/spring/dashboard?execution=e1s1
Rossen Stoyanchev (blog author) says:
Added on January 28th, 2010 at 7:50 amSanjeev, yes the execution parameter in Web Flow 2 is equivalent to the flowExecutionKey as it was called in Spring Web Flow 1.
Ruslans Tarasovs says:
Added on February 9th, 2010 at 3:22 amSee also my JMeter patch (for Web Flow 1.x) here:
https://issues.apache.org/bugzilla/show_bug.cgi?id=48450
Rossen Stoyanchev (blog author) says:
Added on February 9th, 2010 at 11:47 amThanks for posting that, Ruslans.
Have you tried adding the expression extractor to a controller? It should automatically be used for all HTTP request samplers nested within it. See the image above for where exactly it's inserted.
Ruslans Tarasovs says:
Added on March 1st, 2010 at 9:49 amYes, I tried that (I am not _that_ stupid), but it does not work properly. The problem is that you still need to replace your real flow execution key in each and every HTTP request by ${flowExecutionKey}. My patch does it automatically.
Rossen Stoyanchev (blog author) says:
Added on March 1st, 2010 at 10:35 amCould you qualify what didn't work?
Ruslans Tarasovs says:
Added on March 1st, 2010 at 10:49 amAutomatic generation of ${flowExecutionKey} elements did not work.
To reproduce the problem do the following.
1. Add Thread Group and Controller as you did in your example, but not add any HTTP requests yet. Add Regular Expression Extractor as in your example if you wish so.
2. Add HTTP Proxy Server to JMeter workspace. Use your controller as Target Controller.
3. Configure your browser to use JMeter HTTP Proxy Server as proxy.
4. Browse your web application with your web browser.
5. Some HTTP requests will be automatically created under your controller.
6. Check these HTTP requests. You will see that they will include real flow execution keys as parameters instead of ${flowExecutionKey} text. The main task of my little patch is to replace these real keys with "${flowExecutionKey}" text.
Basically the workflow I have given above is typical for any performance testing engineer using JMeter. Nobody is interested in wasting time writing HTTP requests manually for the complex application, so everything is being recorded by HTTP Proxy Server. However, this recording becomes a nightmare if you need to amend these keys manually. Another way is to replace them all using your favorite editor and regexp directly in JMeter data files, but this also is not very interesting thing to do.
Rossen Stoyanchev (blog author) says:
Added on March 1st, 2010 at 11:15 amThat's very useful indeed.
Yogesh Chawla says:
Added on December 20th, 2010 at 11:08 amFor all the Spring web flow 2.0 users, check out this link. It is a simple clever way to handle this issue:
http://theworkaholic.blogspot.com/2010/08/jmeter-with-spring-webflow.html
Ruslans Tarasovs says:
Added on December 21st, 2010 at 5:31 pmIt is very possible that I just did not get it, but it seems that you just say the same as was already said in this article and add nothing new…
You also say there that "Testers seem to get the impression that all they need to do is record and replay the script and they are done." I would say that your testers got perfectly correct impression
Testers should not waste they time programming complex scripts, it is up to programmer to automate the task.
The patch I was discussing there was created specially for that, so the one could record the script and then just replay it. There is no need to update it after recording.
Ruslans Tarasovs says:
Added on December 22nd, 2010 at 7:57 amI am sorry, I just noticed that you are not the author of that blog
Deepak Shetty says:
Added on December 22nd, 2010 at 7:54 pmThat is correct though i did write it independently.
We differ then. These days a tester must know a programming language to be reasonably competent. Do you really think that all a tester needs to do is record a flow and change number of users from 1 to 100 , run a test and he's done(in which case why have a tester at all)? Besides the comment was that for beginners the proxy recorder harms more than helps because they then feel they don't need to understand the application. You can see this in the JMeter mailing lists sometimes, when the recorded script doesn't work , they have no clue as to what they should do next.
Email Extractor Software says:
Added on April 10th, 2011 at 7:37 ami very much like this topic, some really important things to remember have been spoken about email extraction here.