Thursday, 11 June 2015

Virtual Table Server : LoadRunner

Virtual Table Server (VTS)



The Virtual Table Server (VTS) service maintains a database accessible by several clients (load generator) on the same network. 

With VTS, several load generators can obtain values from a single common pool of values. One Vuser can create key values (such as a new customer ID), and any number of other Vusers can immediately use that value.

There are several versions of VTS. The VTS3 comes with LoadRunner 11.52 was completely rewritten to exchange data using REST JSON from a Node.JS server encapsulated in a 64-bit executable.


VTS2 was a 32-bit Windows program and uses an in-memory database.


Installation

Download the file vts2.zip from here: VTS KB Article (HP support login required.) and copy it to your Controller and each and every LG that you intend to run any script referencing VTS on – basically your whole farm. For each machine do this:
1.      Right click the zip file
2.      Select ‘Extract to’
3.      Browse to the directory where LoadRunner is installed (eg. C:\Program Files\HP\LoadRunner)
4.      Choose this folder and the location to extract the zip file to.
5.      Unzip it

1.      Open a CMD Prompt
2.      Type (Only the text inside the brackets…)
3.      Type (Only the text inside the brackets…)

Running VTS

Now you have it installed, think about where you want to run it. Think of each little VTS as a server (they are essentially). So they need to run on a machine that is available to every LG that want s to use it – ie. You have to have network connectivity. You could just use your Controller box but it’s nice to have a separate box for VTS as it can use up a lot of memory and, potentially, network bandwidth.

Once you have a machine in mind, go there and do this:
1.      Open a new notepad document
2.      Type this:
ECHO ON
CD "C:\Program Files\HP\LoadRunner\bin\"
START vtconsole -port 9999 -launch
START vtconsole -port 9992 –launch
 Save this notepad file as ‘START_VTS.bat’. You can use another name if you like but the .bat part is key.
Find the file where you saved it – and double-click it.
Now you should see two windows pop up  with grid control in the center.
I used two VTS servers here to highlight that you can do this – and probably will want to. Each separate server has it’s own PORT number which is how you reference it and you can open lots if you want – think of them as tables in a DB but in reality they are each their own mini database sitting in memory.
Later, when you have started to use VTS, you will appreciate that you can enhance this START_VTS .bat file by using additional params. Eg. –file [FILENAME] will allow you to open the VTS table and pre-populate it with existing data. This data can either be something you have exported from VTS earlier or just plain old delimited text. The new command would look like this:
START vtconsole -port 9999 –launch – file \\MACHINENAME\DIRECTORY\file.csv
You can also setup VTS to export it’s current data to a file and also to periodically update this file. Just select Options > Export / Import.

Connecting to  VTS
Now it is running, you can create a script that uses it. First of all you need to copy this to the vuser_init() section.
#include "as_web.h"
#include "vts2.h"
vuser_init()
{
return 0;
}
Then you need to load the VTS dll and include a reference to the table itself, a bit like this:
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
return 0;
}
Then you need to load the VTS dll and include a reference to the table itself, a bit like this:
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
return 0;
}
Note. MACHINE_NAME/IP is where you have the VTS server(s) running.
For best practice you can improve this code to look like this:
#include "as_web.h"
#include "vts2.h"
vuser_init()
{
PVCI pvci = 0;
int rc = 0;
char *VtsServer = “{VTS_SERVER}”;
lr_load_dll(“vtclient.dll”);
pvci = lrvtc_connect( VtsServer,9944,0);
rc = vtc_get_last_error(pvci);
if( rc != 0 ) {
lr_message(“Connection to VTS %s failed”, VtsServer);
return -1;
}
return 0;
}
Note. {VTS_SERVER} is the name of the machine running VTS.
So you have VTS up and running and your script connects to it. Now you just need to use it.
Using VTS
VTS comes with a document listing all the functions and I am not about to repeat this here, so I attached it. That said, the documentation is poor and contains errors, so beware.
In essence you can write, read, read unique, read a whole row and write a whole row. Think of it like a dat file but the difference is you can read and write to this dat file as the scripts are being executed and all scripts can share the same data.
But you CANNOT query VTS. You can’t say give me all data where CAT_ID=3 or anything like that. Just: give me the next CAT_ID.
When you read data from VTS it has a handy feature where you can read and remove the data from the table – you don’t have to do this but it is generally useful as more often than not you are using VTS because you have context sensitive data that can only be ‘used’ once, or perhaps one at a time. Something like this.
So, how to do all this:
Let’s say you have Script A that is creating orders and Script B that is paying them. Script A would connect to VTS Port 8888 and write data, Script B would also connect to VTS Port 8888 but it would read data.
It would look like this:
Script A
Action()
{
[Do some stuff here to create a new user]
//Now write out the relevant data to VTS
lrvtc_send_row1(“password;email”, “hello123;{p_UniqueUsername}@MYDOMAIN.com”, “;”, VTSEND_SAME_ROW);
return 0;
}
Script B
Action()
{
lrvtc_retrieve_row("email;password",";");
[Do some stuff here using this email and password]
Return 0;
}
Notice that when I wrote the data to VTS I was able to use a parameter {p_UniqueUsername} – this is worth remembering, it’s pretty essential. I also made the example use two columns and thus the retrieve_row function. Also by using ‘retrieve’ row I am removing that row from the table.
You could also have a script that starts by removing a row from a table, then it does some stuff with it, and then it writes it back when it is finished. This enables you to prevent two scripts working on the same record at the same time.
You could also have multiple VTS tables representing ‘states’ of data. For example. An insurance quote needs to be created by a ‘clerk user’ then validated by a ‘super user’ then authorised by a ‘auth user’ – whatever – the point is you have one record going through multiple states and rather than one long script where you have to log in and out multiple times to complete the journey, you use VTS to manage the data.
Finally, something to think about when using multiple tables like this is that sometimes you might find a VTS table empty. In this scenario you need to code a do, while loop that polls the VTS table looking for a record before carrying on. This prevents the script failing and, if you code the loop well, it will prevent over loading your system artificially.
Conclusion
Anyone with data that can only be used once, with data that they want to pass between scripts or with data that they generate during the run that they want to keep, should use VTS. Basically that’s pretty much anyone using LR.

Sunday, 7 June 2015

SiteScope Monitoring Features



SiteScope provides a set of features which help us to monitor key functionalities of server or web application. SiteScope also has integrated alarming system which can used in server monitoring.

Please refer the features available in SiteScope Tool:

Feature
Description
Agentless architecture
SiteScope application design speeds deployment by eliminating the need to install agent software on the servers and systems you want to monitor
Alert schedules
Gives you the option of enabling alerts during certain times of the day or week
Alert template customization
Lets you customize the data sent in e-mail, pager, and other alert types
Browser interface
View, configure, test, and manage your monitoring environment locally or remotely through a web browser interface
Common file formats
Monitoring data and templates are stored in text file formats allowing you to export a wide range of third party applications
Composite Monitor
Acts as a monitor container allowing you to filter and customize alerting on redundant or parallel systems
Content matching on results
Extend the versatility of monitoring by checking for specific content on web pages, in system logs, in databases, and other systems using the flexibility of regular expressions
Custom monitor API
Develop your own monitor types to adapt and integrate SiteScope with custom applications and environments
Database interoperability
Log monitoring data to a JDBC compliant database for efficient storage and extended reporting with third party analysis tools. SiteScope's Dynamic Update feature can regularly query a database table and automatically create sets of monitors whenever new IP addresses are detected in the database.
Database monitoring
Simulate client interactions with JDBC compliant databases and also monitor database server performance parameters
Diagnostic tools
Use a built-in array of diagnostic tools mirroring monitor functionality to quickly troubleshoot connectivity and monitor issues through the product interface
E-mail monitoring
Verify that business-critical e-mail communications are operating by sending and receiving e-mail messages
End-to-end web based sequence monitoring
Confirm that a complete sequence of web-based, back-end, and e-mail actions are executed correctly and in the proper order using the eBusiness Chain Monitor.
Flexible monitor error thresholds
Select from different parameters and values to set the Error, Warning, and Good status of each monitor.
Fault recovery automation
Automate failure recovery actions by combining system monitoring with versatile Script alerts
Monitor-to-monitor dependency relationships
Build enable-disable relationships between monitors and groups to suppress redundant alerts from sets of monitors that are dependent on the same systems.
Monitor Browser
Quickly view all monitors in your set up and filter according to status, name, type, or other criteria
Multiple SiteScope installations
Link and view multiple SiteScope installations in your environment in a a single interface using the Multi-view feature.
Monitor templates
Speed deployment of your monitoring by creating monitor templates that can rapidly configure common monitors over multiple servers
Remote server monitoring
Monitor systems running on Windows, UNIX, and Linux using SiteScope running on Windows NT/2000 or monitor other Unix systems with SiteScope running on Solaris or Linux
Scheduled maintenance task automation
Automate routine system management tasks by combining system scripts with the flexible Script Monitor
Server performance monitoring
Monitor performance metrics for many popularly used application servers
SiteScope - Topaz Managed Services integration
Integrate SiteScope availability monitoring with Mercury Interactive's remote Topaz Managed Services (TMS) by configuring SiteScope to be an TMS agent
SiteScope - SiteSeer integration
Integrate remote monitoring data from SiteSeer accounts directly to the SiteScope Main Panel
SiteScope - Topaz integration
Integrate SiteScope availability monitoring with Mercury Interactive's Topaz Console by configuring SiteScope to be a Topaz agent
SNMP integration and support
Configure SiteScope to be an SNMP agent reporting to other SNMP management consoles. Conversely, use SiteScope's built in SNMP support to monitor other SNMP enabled devices
System level monitoring
Increase the depth of your monitoring and speed troubleshooting with system resource and log monitoring
URL monitoring
Monitor URL availability and content with versatile URL monitoring options

Saturday, 6 June 2015

How do I calculate the number of concurrent users to use in a load test?

Running a load test requires that you specify how many concurrent users should be simulated during testing. In other words, how many simulated users will be active, loading things or interacting with your site/app at the same time. Unfortunately, when looking at Google Analytics for example, we only see how many visits a website has per day or per month. A site can have a million visits per month, but still only ever experience max 100 concurrent visitors.
To convert the "visits per X" metric from Google Analytics, or some other analytics system, into a "concurrent users" metric that you can use for load testing, you can use the following method.
First, find out two things:
  1. You need the total number of visits for a short time period when your site/app is at peak traffic levels. This can easily be found via e.g. Google Analytics by seeing what the highest number of visits was for a single hour in the course of e.g. a month. Look at the day that has seen the highest number of visits, and drill down to see what hour of that day was the busiest and how many visits you had during that hour. Note this value down. I will call this value "peak_hourly_visits" in this text.
  2. You need to know the average time a user spends interacting with your site/app. In Google Analytics this is called "Average session duration" and I will call it that in this text also, but sometimes it is called "Average time on site". If this value changes a lot for your site/app depending on which time period you look at you might want to use one of the larger values you find, to be on the safe side. We want all times in seconds, so if e.g. Google Analytics tells you "00:03:19" (3 minutes, 19 seconds) you should note down 199 as the average session duration.
When you have those two values you use this formula to calculate the number of concurrent users to use in your load test:

concurrent_users = (peak_hourly_visits * average_session_duration) / 3600

Provided that each simulated user (VU) in your load test behaves realistically (i.e. simulates a real user well), you will now be able to stress your site/app with the same kind of traffic that it normally only sees during peak traffic hours.

Load Generation - Revisted



If your only goal is to simulate a certain number of transactions in a certain time period, you can do that with quite few virtual users in the test.
If your average transaction time for 7 transactions is 16 seconds it means you can do 7/16 transactions per second, using a single virtual user.
To get 10,000 transactions in an hour you would have to use multiple concurrent virtual users.
VU = Number of virtual users
time = test time in seconds
TPS = transactions per second

VU * time * TPS = total_transactions
In this case we know total_transactions but not VU, so we rewrite it to:
total_transactions / (time * TPS) = VU
Using the numbers we have, we get:
10000 / (3600 * 7/16) = 6.3
I.e. you need more than 6 VUs to get 10k transactions in one hour. Maybe go for 10 VUs and insert some sleep time as necessary to hit the exact 10,000 transactions.
How much sleep time and how many iterations would you get then?
10 users executing at 7 transactions per 16 seconds for one hour would execute a total of 10 * 7/16 * 3600 = 15,750 transactions. We need to slow the users down a bit. We need to make sure they don't do the full 7/16 transactions per second. We can use the formula again:
VU * time * TPS = total_transactions

TPS = total_transactions / (VU *time)

TPS = 10000 / (10 * 3600)   =>  TPS = 0.2777...
We need to make sure the VUs only do 0.28 TPS, rather than 7/16 (0.44) TPS.
TPS = transactions / time
Your script does 7 transactions in 16 seconds, to get 7/16 (0.44) TPS.
To find out how much time the script needs to take, we then change it to:
Iteration time = (No transactions per Iteration * Vu) / TPS

time = 7 / 0.277778   => time = 25.2 seconds
Alternatively way (10000/7)= 1428/3600==>0.39 so 10=0.39*p ==> 25.2
Currently, your script takes 16 seconds, but we need it to take 25 seconds, so you need to add 9 seconds of sleep time.
So:
10 VUs, executing 7 transactions in 25 seconds, over the course of an hour, would produce 10,000 transactions:
10 * 7/25 * 3600 = 10080
The number of script iterations each VU would perform would be:
3600 / 25 = 144 iterations
To sum up:
Number of VUs: 10
Total sleep time during one iteration: 9
Iterations/VU: 144

Lets take an example scenario: There is an application for which current production volume for 100 concurrent users are 1M transactions per 1 hour. Also there is an estimate that in future the transaction will grow from 1M to 1.5M.  

Solution: Lets create a load runner script which has 6 transaction/ Iteration.So with the above data given , below are the possible workload model that we can design by tuning Pacing& users. 




Simple steps to calculate:
1. run the 1 user test and note down the no. transaction in the script and collect the Total TPS
2. collect the production value data like ( total no. of txn completed for hr/min/day).
3. Now use the formula to get the Vu required to meet the production volume:=> Vu=total txn/(total    tps*Duration)
4. Now increase the volume of users to calculate the additional Pacing time required. TO do this calculate the new Total TPS= Total Txn/(increased Vu* duration).
5 With the new Total TPS calculate Iteration Pacing=(no. of txn in the script)/(New Total TPS)

Example 2:
=============
for one of the banking application there are 1875 transaction observed for  an hour. Also as per the test plan 750 are active on the system.

solution:

To simulate above workload how much pacing is required.
TPS=1875/3600 =0.52

Pacing == 750/0.52 ==>24 min
which means to simulate 1875 of load with 750 users we need pacing of 1444 sec

But another challenge in simulating the load is we can't able to reach above data when we go for the slow rampup and rampdown of the users as this will mask the actual load.

The solution for this issue includes noting down the steady state txn for ex: for 1 hr  we will achieve say 1560 txn.

Diff 1875-1560==315

==>315/1875=16%

So we need to reduce hte pacing of 16% == > 1444-(16*1444/100) ==>1212sec >>20min

============================
1. Run the single uesr test and get the TPS= 7/16
2. Now get the Total TPS=10000/3600
3. now get the users
4. increase the users and pacing
5. calucate the pacing==> 10=0.39*P
===============================