Labels

Monday, July 2, 2012

LoadRunner Internal Architecture?

Click to enlarge











  1. application servers under test are placed under stress by
  2. driver processes mdrv.exe (the Multi-threaded Driver Process) and r3vuser.exe which emulate application clients such as Internet Explorer web brower. It performs 3 main actions:
      Kli> cpp (C language pre-processor)
    1. cci (C pre-compiling) which creaes a file with ci file, and
    2. execute using the driver for the protocol technology being tested.
    Runs can be invoked to run "silently" by invoking Mdrv.exe from a Windows batch script.
    Mdrv can automatically stop loading Vusers because they communicate with Vusers and monitor CPU usage on Windows Load Generator machines.
    A separate JVM is instantiated by each Java-based Vuser on Windows-based machines. Java Vusers are not supported on Unix platforms.
  3. virtual Vusers are invoked as groups (logical collection of virtual users running the same script on a specific load generator machine)
  4. by agents (3,900K magentproc.exe) running as a service or as a process
  5. on load generator client machines.
  6. Each machine hosting agents maintains an Execution Log in a .qtp file.
  7. When logging is enabled, the agent also creates within the results folder a sequential log file for each Vuser (segregated by Vuser group).
  8. During execution, this file is displayed in the view > Show Output window on the LoadRunner Controller machine.
  9. Upon a pre-set delay, the Scheduler running on a Controller machine instructs agents (via Windows port 54345 or dynamic Unix port) to initiate test session scenarios. The Controller (wlrun.exe) sends a copy of scenario files along with the request.
  10. Agents are launched by the Remote Agent Dispatcher process (formerly called Remote Command Launcher (RCL)) on each load generator machine.
  11. Each agent refer to scenario (.lrs) definition files to determine which Vuser groups and scripts to run on host machines. Idea This means the Controller can be started from a DOS batch (.bat) file (preferrably with a short name on a root drive):
      REM Start Controller: SET M_ROOT=C:\Program Files\HP\LoadRunner\bin cd %M_ROOT% wlrun.exe -TestPath D:\Dev\Dev1.lrs -port 8080 -Run -DontClose pause Press Ctrl-Z to keep this window or
    • Including the -Run parameter is the same as manually pressing the "Start Scenario" automatically upon invocation. This is not a good idea because you may have to decide about collating the file from a previous run or want to change the output folder.
    • This assumes that the system's environment PATH variableanother page on this site was updated to include where LoadRunner is installed.








  1. The Controller is invoked using parameter values within files in the Windows OS folder (WINNT for Windows 2000 and WINDOWS for Windows XP). The Windows folder is used because LoadRunner is designed to have only one instance of Controller running at a time on a machine.
      Idea To quickly switch among several applications, save a copy of LoadRunner's ini files after working on it within the Controller, then use Notepad to craft a batch fileanother page on this site to copy application-specific versions of ini files before executing wlrun. An example of file copy actions for application XXX:
        copy %LRDir%/config/wlrun7-XXX.ini   %LRDir%/wlrun7.ini copy %LRDir%/config/wlrun7-XXX.dft   %LRDir%/wlrun7.dft
      Prior to v9.0:
        copy %WinDir%/wlrun7-XXX.ini   %WinDir%/wlrun7.ini copy %WinDir%/wlrun7-XXX.dft   %WinDir%/wlrun7.dft
    Some defaults you might want to change:
    • In the wlrun7.ini file file [output] section, MaxNumberOfOutputMessages= from 10000 to 100000 for long runs. This limits the number of output messages stored in the database.
    • MaxOutputUIRowsToShow limits the amount of messages/errors (lines) displayed in the Controller's Output window.
    • In the QTWeb.lrp file within the LoadRunner Program Files dat\protocols folder section [Vugen], add entry MaxThreadPerProcess=5 to limit the number of threads managed by each load generator mdrv.exe process.
    Values for DefaultScenarioDir, DefaultScriptDir, DefaultResultDir, and [Recent File List] stored in the wlrun5.ini and wlrun7.dft files updated whenever values are changed within the Controller.
  2. The blocks of actions taken by each Vuser are
  3. defined in Vu scriptsanother page on this site created using Loadrunner's VuGen.exe. When this program is invoked, it stores in the Windows folder a comparamui.INI file to save under "[LastTablesUsed]" a history of files and [ParamDialogDates] specified using menu option Insert > New Parameter > Dates. VuGen stores and retrieves a vugen.ini file in the Windows folder. When using Java, enable additional debug options:
      [DynaDlg] JavaLevel=3
    When using 8.0 scripts within VuGen 8.1, add to Vugen.ini:
      [Editor] OLDEDITOR = 1
    VuGen opens in LR folder template/qtweb default.cfg and script files.
    Vu scripts can be coded to use variable values obtained from parameter files external to the script.
    I have a lot more on VuGenanother page on this site here
  4. During a run, execution results are stored to a results folder.
      Idea I prefer to set Results Settings to "Automatically create a results directory for each scenario execution." which means that LR will increment the name of the Results Name when I start a scenario runs. For example, a value of "Res11" will be automatically incremented to "Res12" or sometimes "Res11-1".
    Errors are written to the output.mdb MS Access database. tool See the ASP page I have written to access this databaseanother page on this site
  5. Within each results folder, a "Log" folder is automatically created to contain a log file for each group. After a run, to view a log file from within the Controller, click Vusers button then right-click on a group to select "Show Vuser Log".
  6. As a scenario is run, monitors maintain counters locally on each host.
  7. After a run, the "collate" process takes .eve and .lrr result files and creates in the results folder a temporary .mdb (MS-Accessanother page on this site) database. To prevent errors when processing large result files, use MSDE (Microsoft SQL Desktop Engine).

      setup SAPWD="StrongPassword" INSTANCENAME="LR" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0 /L*v path to log file
    Using Windows Explorer, share the Data folder.
    Then in Analysis Options > Database tab, use 8.3 names without spaces (indentified with DOS command DIR /X):
    1. Input the SAPWD password specified above.
    2. Logical Storage location: \\loadclient02\Data (the folder you shared)
    3. Physical Storage Location: C:\PROGRA~1\MICROS~1\MSSQL\Data (not C:\Program Files\Microsoft SQL Server\MSSQL\Data)
    4. Click "Test parameters". (This takes a few seconds)
  8. The Analysis Module (8,320K analysisu.exe)
  9. generates analysis graphs and reports using data from the .mdb database.
  10. The LoadRunner Results file results_name.lrr from each scenario run -- also called an Analysis document file -- is read by the Analysis program to display Percentile graphs.
  11. By default, the LRReport folder is created in the test analyst's local machine My Documents folder to store Analysis Session files.
  12. They can optionally be formated in HTML.
  13. Their format are controlled by a .tem template file.
  14. Optionally, Mercury's Remote Performance Monitoring (RPM) MS-IIS/ASP web server for LoadRunner 7.8 can be installed on a Windows 2000 server (Caution! but not on a Windows 2003 server) so that
  15. load test results to be viewed using a web browser.

How loadrunner Works?

http://merc.tv/img/scr/lr/how_load_runner_works.gif






Unlike a
WinRunneranother page on this site workstation which emulates a single user's use of a client, LoadRunner can emulate thousands of Virtual Users.
Load generators are controlled by VuGen scripts which issue non-GUI API calls using the same protocols as the client under test. But WinRunner GUI Vusers emulate keystrokes, mouse clicks, and other User Interface actions on the client being tested Only one GUI user can run from a machine unless LoadRunner Terminal Services Manager manages remote machines with Terminal Server Agent enabled and logged into a Terminal Services Client session.
During run-time, threaded vusers share a common memory pool. So threading supports more Vusers per load generator.
The Status of Vusers on all load generators start from "Running", then go to "Ready" after going through the init section of the script. Vusers are "Finished" in passed or failed end status. Vusers are automatically "Stopped" when the Load Generator is overloaded.
No additional license is needed to monitor standard web (HTTP) servers (Apache, IIS, and Netscape).
To use Web Services Monitors for SOAP and XML, a separate license is needed, and vUsers require the Web Services add-in installed with Mercury Feature Pack (FP1)

Load Runner Architecture Overview?

    LoadRunner works by creating virtual users who take the place of real users operating client software, such as Internet Exploreranother page on this site sending requests using the HTTP protocol to IIS or Apache web servers. Requests from many virtual user clients are generated by "Load Generators" in order to create a load on various servers under teston this page These load generator agents are started and stopped by the "Controller" program. The Controller controls load test runs based on "Scenarios" invoking compiled "Scripts" and associated "Run-time Settings". Scripts are crafted using the "Virtual user script Generator" (named "V U Gen"), It generates C-language script code to be executed by virtual users by capturing network traffic between Internet application clients and servers. With Java clients, VuGen captures calls by hooking within the client JVM. During runs, the status of each machine is monitored by the Controller. At the end of each run, the Controller combines its monitoring logs with logs obtained from load generators, and makes them available to the "Analysis" program, which can then create run result reports and graphs for Microsoft Word, Crystal Reports, or an HTML webpage browser. Each HTML report page generated by Analysis includes a link to results in a text file which Microsoft Excel can open to perform additional analysis.

Sunday, July 1, 2012

Difference between Application Server and Web Server in Java ?

Application server and web server in Java both are used to host Java web application. Though both application server and web server are generic terms, difference between application server and web server is a famous J2EE interview question. On  Java J2EE perspective main difference between web server and application server is support of EJB. In order to run EJB or host enterprise Java application (.ear) file you need an application server like JBoss, WebLogic, WebSphere or Glassfish, while you can still run your servlet and JSP or java web application (.war) file inside any web server like Tomcat or Jetty.


Application Server vs Web Server


1. Application Server supports distributed transaction and EJB. While Web Server only supports Servlets and JSP.
2. Application Server can contain web server in them. most of App server e.g. JBoss or WAS has Servlet and JSP container.

3. Though its not limited to Application Server but they used to provide services like Connection pooling, Transaction management, messaging, clustering, load balancing and persistence. Now Apache tomcat also provides connection pooling.

4. In terms of logical difference between web server and application server. web server is supposed to provide http protocol level service while application server provides support to web service and expose business level service e.g. EJB.

5. Application server are more heavy than web server in terms of resource utilization.

Personally I don't like to ask questions like Difference between Application Server and Web Server. But since its been asked in many companies, you got to be familiar with some differences. Some times different interviewer expect different answer but I guess on Java's perspective until you are sure when do you need an application server and when you need a web server, you are good to go.

How to Tuning JRockit ?

Tuning the Heap Size:
  • A large heap decreases the garbage collection frequency but may take slightly longer to garbage collect.
  • Typically a heap should be at least twice the size of the live objects in the heap.
  • Should set the heap as large as the PHYSICAL memory in your system will allow, as long as it doesn’t cause paging.
  • -Xms:, which sets the initial and minimum heap size.
  • -Xmx:, which sets the maximum heap size.
  • Set the initial/minimum heap size (-Xms) to the same value as the maximum heap size (-Xmx).
Tuning the Garbage Collection
  • JRockit offers three garbage collection modes and a number of static garbage collection strategies. You can tune the garbage collection to suit your application’s needs.
  • -XgcPrio:throughput: Defines that the garbage collection should be optimized for application throughput. This is the default garbage collection mode.
  • -XgcPrio:pausetime : Defines that the garbage collection should be optimized for short garbage collection pauses.
  • -XgcPrio:deterministic {Only with JRockit Real-Time}: Defines that GC should be optimized for very short and deterministic garbage collection pauses.
Tuning the Pause Target
  • This parameter is used to tune JVMs which host ‘time critical applications’ (Ex: A banking application  that normally take 100 ms to complete and times out after 400 ms, cannot afford a GC pause time of 500ms)
  • The pause time mode uses a pause target for optimizing the pause times; pause target should be as high as your application can tolerate
  • This parameter is coupled and used with ‘-XgcPrio:pausetime’ (ex: java -XgcPrio:pausetime -XpauseTarget:300ms weblogic.Server); default ‘pauseTarget’ is not specified is 500ms

# Below given parameters should not be changes until you
feel a real need to tune your Weblogic server; incorrect
 tuning may lead to uneven performance degradation.


Tuning Compaction
  • Whenever GC(old collection) runs it defragments the heap, making object allocation easier for the JVM this process is called heap compaction; compaction may lead to long pauses in GC because it takes up the CPU time to arrange and defragment the heap
  • -XXcompactRatio:centage> : this specifies the percentage of heap which will be defragmented when GC runs;  a good value for the compact ratio is usually between 1 and 20; a too low value can also invite trouble as it slows down defragmentation and increases the amount of dark matter(“Dark matter” is wasted heap memory and fragments the heap)
  • -XXcompactSetLimit:<references> : When compaction has moved objects, the references to these objects must be updated. JVM has to do this before threads have access to those memory references; this parameter defines how many references GC can compact within the compaction area (Ex: java -XXcompactSetLimit:20000 MyApplication)
Tuning the TLA (Thread Local Area)
  • It is the chunk of memory reserved in the heap for a thread for its exclusive use.
  • When this TLA gets filled up we see the ‘java.lang.OutOfMemoryError: nativeGetNewTLA’, to fix this we can tune the ‘-XXtlaSize:min=e>,preferred=’ parameter increase the TLA (Ex: -XXtlasize:min=8k,preferred=512k)
  • Increasing the TLA size is beneficial for multi threaded applications; however increasing it too much may result in more fragmentation and more frequent garbage collections.

Weblogic Server Administration Server Interview Questions?

  • What are clusters?
Ø  Cluster is a logical set of multiple Weblogic Server instances running simultaneously across different geographies and working together to achieve  high availability and scalability
Ø  Weblogic Server clusters support multiple algorithms for load balancing and failover: round-robin, weight-based, random, round-robin-affinity, weight-based-affinity, and random-affinity(By default, a Weblogic Server cluster will use the round-robin method)
  • What is session replication?
Ø  Weblogic Server provides clustering support for servlets and JSPs by replicating 'HTTP session state' of clients that access servlets and JSPs through a cluster service
Ø  Weblogic Server can use 'memory, file based and database' persistence for storing session information
  • How you deploy your applications on weblogic server?
Ø  Auto Deployment
Ø  Console
Ø  Command line – weblogic.deployer
Ø  ANT / WLST
  • What are stating modes are available in Weblogic Server ?
Ø  Stage mode: Administration Server copies the deployment files from their original location on the Administration Server machine to the staging directories of each target server
Ø  External Stage: target servers deploy using local copies of the deployment files, here the Administration Server does not automatically copy the deployment files to targeted servers in external_stage mode ; instead, you must copy the files to the staging directory of each target server before deployment.
Ø  No Stage: The Administration Server does not copy deployment unit files; instead, all servers deploy using the same physical copy of the deployment files, which must be directly accessible by the Administration Server and target servers.
  • What is a Thread dump? How will you take in unix/linux and windows?
Ø  A Java thread dump is a way of finding out what every thread in the JVM is doing at a particular point in time. This is especially useful if your Java application sometimes seems to hang when running under load, as an analysis of the dump will show where the threads are stuck.
Ø  Linux : kill -3 <ps_id>
Ø  Windows (console mode) : crtl+break
Ø  Windows (service) : beasvc -dump -svcname:mydomain_myserver
  • How should u look for in a Thread Dump?
Ø  Always have 7-10 thread dumps taken in an interval of 5 seconds each
Ø  A thread dump will give you an insight on what every thread in the JVM is currently doing
Ø  While analyzing the thread dump you should be looking for stuck threads (threads which have not moved from a long time) – could be a resource (file / db) lock not allowing the thread to complete the task and free the monitor
Ø  Look for thread locsk(if two threads store references to different objects into the same reference value, the variable will subsequently contain a reference to one object or the other, not a reference to some other object or a corrupted reference value)
Ø  Look for recursive loops in application / server code traces, usually hampers server performance by utilizing CPU
  • What is difference between 8.1 and 9.2, 10.x versions?
Ø  8.1 uses JDK 1.4.2 ; 9.2/10.0 uses JDK 1.5 ; 10.3 uses JDK 1.6
Ø  8.1 uses execute worker threads ; 9.2/10/10.3 uses work manager for work load distribution within the server
Ø  Directory structures
Ø  Console applet bases in 8.1 ; while it is portlet based in later versions
Ø  8.1 has one big config.xml ; later versions have basic info in config.xml and subsystem level info in different directories(jms, jdbc, etc)
  • What are multi pools / multi data sources?
Ø  MultiPools are 'pools of connection pools' that you can set up according to either a high availability or load balancing algorithm
Ø  You can use a MultiPool in the same manner that you use a connection pool.
Ø  When an application requests a connection, the MultiPool determines which connection pool will provide a connection, based on the selected algorithm
  • What is IIS server?
Ø  IIS is a webserver developed by Microsoft which is shipped with Windows NT/2000/2003 +
Ø  Available versions : 5, 6, 7
Ø  Usually used for hosting static HTML pages and used as an aplkication server for ASP.NET application developed using DOT NET framework 1+.
Ø  Can be used as a proxy server for routing requests to weblogic server
  • Where are user credentials stored?
Ø  User credentials are stored in the 'boot.properties' file , which has its encryption key in the 'SerializedSystemIni.dat'
Ø  If you use a script to start a server instance, it is recommended that you do not use this technique because it requires you to store an unencrypted password in the startup script.
  • Suggest few JVM tuning parameters.
Ø  Initial heap size and maximum heap size to be same (-xms and –xmx):T his ensures less is spend by the CPU to allocate memory in rutime
Ø  Young generation (-XX:MaxNewSize): The bigger the young generation, the less often minor collections occur. However, for a bounded heap size a larger young generation implies a smaller tenured generation, which will increase the frequency of major collections. The optimal choice depends on the lifetime distribution of the objects allocated by the application.

WLST on Weblogic 8.1


In WLS 9.0 onwards WLST in inbuild with weblogc.jar, but for WLS 8.1 you would need use the jython.jar and wlst.jar files in order to run WLST.


You will have to add both these files in the beginning of the CLASSPATH varibale in setWLSenv.cmd/.sh

Eg: set CLASSPATH=C:\Installer\wlst_v62\jython.jar;C:\Installer\wlst_v62\wlst.jar;C:\Installer\wlstExplorer\wlstExplorer.jar;%WEBLOGIC_CLASSPATH%;%CLASSPATH%

How to run:
1. Open a new command window
2. Run the 'setWLSenv.cmd/.sh' script to set the enviroment variables
3. invoke WLST in interavtive mode using the follwowing command : 'java weblogic.WLST'