Thursday 20 February 2014

Multi-threading??? Say what..!?

Let me explain what is Multi-threading.

Assume you have a simple Java class with a method to add two numbers.

public void addNum(int a, int b){

......

}

Lets say person "A" wants to execute this program to add two number. We know that is possible!

Lets say person "B" also wants to execute this program. Here we have 2 different scenarios

1. B can execute after A finishes execution - This is sequential execution
2. B can make another copy of this program and execute on a different machine - This is parallel execution

But how can "B" execute this program in parallel, but without making duplicate copies of this program.

This is were Multi-Threading comes into picture
Multi-Threading allows parallel execution of a program without creating multiple copies of that program.

Multithreading is a process of executing multiple threads simultaneously. A thread is a lightweight subprocess, a smallest unit of processing. It is a separate path of execution. It shares the memory area of process. So in short, Multithreading is a technique that allows a program or a process to execute many tasks concurrently (at the same time and parallel). It allows a process to run its tasks in parallel mode on a single processor system.

Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

A multithreading is a specialized form of multitasking. Multitasking threads require less overhead than multitasking processes.

A process consists of the memory space allocated by the operating system that can contain one or more threads. A thread cannot exist on its own; it must be a part of a process. A process remains running until all of the non-daemon threads are done executing.

 Multithreading enables you to write very efficient programs that make maximum use of the CPU, because idle time can be kept to a minimum.

In Java, the Java Virtual Machine (JVM) allows an application to have multiple threads of execution running concurrently. It allows a program to be more responsible to the user. When a program contains multiple threads then the CPU can switch between the two threads to execute them at the same time. 

For example, look at the diagram shown as:



In this diagram, two threads are being executed having more than one task. The task of each thread is switched to the task of another thread.

Advantages of multithreading over multitasking :  

    Reduces the computation time.
    Improves performance of an application.
    Threads share the same address space so it saves the memory.
    Context switching between threads is usually less expensive than between processes. 
    Cost of communication between threads is relatively low.


Sunday 13 May 2012

Pacing and Pacing vs Think Time


What is the impact when we add pacing in the script? and how is this different from Think Time?


           Adding pacing in the script gives user the control to determine how long it takes for each iteration to complete. Think time is something very basic. All you can do with think time is to let the script think for certain secs before proceeding. But this lacks control. Adding pacing to the script can compensate this problem. In some case, we would like to control the TPM/Volume/Throughput and hence usage of pacing. Think time is fixed. But pacing can be altered and controlled easily. Load runner provides three different options to control/add pacing. They are

  1. As soon as the previous iterations ends
  2. After the previous iterations ends (fixed time)
  3. At a random interval xx to xx secs.

Monday 20 February 2012

Concurrent Users vs Simultaneous Users


Simultaneous Users: Lets say that users are logging into application, send a mail and logout. In this process, every user will wait for the other user to complete the entire transaction before logging. here at any point in the scenarion no 2 users are logged in to the system. simple words one after the other.

Concurrent Users: There are 3 different levels of concurrency.
1. Application level
2. Business process level
3. Transaction level

Taking the above example

  • Application level : two users login but one user can send a mail and other can read a mail. Notice 2 users although active at the system at the same time, they perform 2 diffferent processes.
  • Business process level: two users login to the system and send mails. But they dont login at the same time and send mails. It can so haapen that one user is coposing amil, 2 nd user logs in. first users sending  a mail, second user composing. ...and so on..Point to notice here is 2 u sers are active on the system doing the same busineess process but niot all actions at a time.
  • Transactin level: 2 users login at teh same time, compose at the same tiem and sends mail at the same time and logs out at teh same time. (Randezvous).


Overall when we say 10 concurrent  users, 10 users are currently active on the system at that point of time. When we say 10 simultaneous users which is not the case.

Saturday 10 December 2011

Decompression Errors



  1. Z_Data_ERROR
  2. Z_MEM_ERROR
  3. Z_BUFFER_ERROR


Z_DATA_ERROR: This means that the response received by LR as a response to a request cannot be decompressed either due to bad data or data being corrupted on its way. If you are getting very low amount of these kind of error messages, it either means that your load generator is overloaded or you have network issues intermittently which is corrupting the packets or your servers are having some kind of bottlenecks and due to these bottlenecks they are not in position to send the complete file to the client.

Normally by looking at the content length received from the server response over the duration of time for the same request,one can make out if the server is having the any kind of bottlenecks.If content length looks similar across many requests and if LoadRunner has successfully decompressed some requests and some have failed, it means that either your LG’s are overloaded or you are having networks issues which corrupts the data flowing across the wire.

Z_MEM_ERROR: This error is received if for some reasons your LG’s boxes are running low on memory requirements,and due to less amount of memory,LoadRunner is not able to decompress the server response.Monitor your Load Generator boxes for memory usage.

Z_BUFFER_ERROR: This means LR doesn't have enough buffer size to accept response for an request. Check out my previous post which has the solution for this.

Friday 9 December 2011

Why do we need a dryrun?

Why is a Dryrun?
Before executing any actual test we execute same scripts for a smaller duration of time. This is called as a Dryrun.

Why do we need this?
There are few important reasons why we perform a dryrun before we begin our actual test

  • Server warm-up (Usually servers are bounced before starting the test. Its a good practice in fact)
  • Checking for transaction failures (script errors or server side issues or application issues)
  • To avoid caching issues which might create outliers

Network Buffer


What is Network Buffer?
Network buffer size sets the maximum buffer size that receives HTTP response from the server. 

How does it impact my test?
If the size of response is huge, then the server will send data in chunks. This will be an overhead to the system when multiple Vusers are running. Default size of network buffer is around 12KB. Follow below mentioned steps to increase the size of network buffer.

  • On a WIN 7 system, go to C:\Program Files (x86)\HP\LoadRunner\dat
  • Open file called "WebAdvancedOpt.txt"
  • Go to line which looks something like this "6="T_EDIT_NUM;Web;NetBufSize;Network buffer size; ..."
  • By default, 12288 Bytes is the size of network buffer. This can be increased anything less than 32KB


Thursday 29 September 2011

Mastering vi Editor




1. Start-up
vi filename

2. vi Modes
vi has two modes

  •     Command mode: In command mode, the letters of the keyboard perform editing functions (like moving the cursor, deleting text, etc.). To enter command mode, press the escape <Esc> key. By default vi starts in command mode. 
  •     Insert mode: In insert mode, the letters you type form words and sentences. Unlike many word processors, vi starts up in command mode.

3. Entering Text
Press i
If you make a mistake, pressing <Backspace> or <Delete> may remove the error, depending on your terminal type.

4. Moving the Cursor
To move the cursor to another position, you must be in command mode. If you have just finished typing text, you are still in insert mode. Go back to command mode by pressing <Esc>. If you are not sure which mode you are in, press <Esc> once or twice until you hear a beep. When you hear the beep, you are in command mode.
The cursor is controlled with four keys: h, j, k, l.

     Key        Cursor Movement
     ---        ---------------

     h        left one space
     j        down one line
     k        up one line
     l        right one space
   
5. Undoing
To undo your most recent edit, type
     u
To undo all the edits on a single line, type
     U (uppercase)
Undoing all edits on a single line only works as long as the cursor stays on that line. Once you move the cursor off a line, you cannot use U to restore the line.

6. Closing and Saving a File
With vi, you edit a copy of the file, rather than the original file. Changes are made to the original only when you save your edits.

To save the file and quit vi, type
     ZZ
The vi editor editor is built on an earler Unix text editor called ex. ex commands can be used within vi. ex commands begin with a : (colon) and end with a <Return>. The command is displayed on the status line as you type. Some ex commands are useful when saving and closing files.

To save the edits you have made, but leave vi running and your file open:

    Press <Esc>.
    Type :w
    Press <Return>.

To quit vi, and discard any changes your have made since last saving:

    Press <Esc>.
    Type :q!
    Press <Return>.