Tuesday, March 4, 2014

Heap Memory Demystified

Memory pool

Memory Pool in JVM is divided into two main areas:
1. Heap Memory
2. Non-Heap Memory

Heap memory

The heap memory is the runtime data area from which the Java VM allocates memory for all class instances and arrays. The heap may be of a fixed or variable size. The garbage collector is an automatic memory management system that reclaims heap memory for objects.
  • Eden Space: The pool from which memory is initially allocated for most objects.
  • Survivor Space (Young Generation): The pool containing objects that have survived the garbage collection of the Eden space.
  • Tenured Generation (Old Generation): The pool containing objects that have existed for some time in the survivor space.



Non-heap memory

Non-heap memory includes a method area shared among all threads and memory required for the internal processing or optimization for the Java VM. It stores per-class structures such as a runtime constant pool, field and method data, and the code for methods and constructors. The method area is logically part of the heap but, depending on the implementation, a Java VM may not garbage collect or compact it. Like the heap memory, the method area may be of a fixed or variable size. The memory for the method area does not need to be contiguous.
  • Permanent Generation: The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.
  • Code Cache: The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.

Thursday, January 23, 2014

Coherence Web Cache in webshphere

Coherence*Web is an HTTP session management module dedicated to managing session state in clustered environments. Built on top of Coherence, Coherence*Web: brings Coherence data grid’s data scalability, availability, reliability, and performance to in-memory session management and storage; allows storage of session data outside of the Java EE application server, freeing application server heap space and enabling server restarts without session data loss; enables session sharing and management across different Web applications, domains and application servers. More information can be found in the post Setting-up a WebLogic Cluster that uses Coherence.
ActiveCache is employed by applications running on WebLogic Server and provides replicated and distributed caching services that make an application’s data available to servers in a Coherence data cluster. ActiveCache provides direct access by applications to data caches, either through resource injection or component-based JNDI lookup, and lets us display, monitor, create, and configure Coherence clusters using the WebLogic Server Administration Console and WLST.
- See more at: http://middlewaremagic.com/weblogic/?p=8351#sthash.mus5EgxS.dpuf

UDP (User Datagram Protocol)vs TCP

UDP (User Datagram Protocol) is a communications protocol that offers a limited amount of service when messages are exchanged between computers in a network that uses the Internet Protocol (IP). UDP is an alternative to the Transmission Control Protocol (TCP) and, together with IP, is sometimes referred to as UDP/IP. Like the Transmission Control Protocol, UDP uses the Internet Protocol to actually get a data unit (called a datagram) from one computer to another. Unlike TCP, however, UDP does not provide the service of dividing a message into packets (datagrams) and reassembling it at the other end. Specifically, UDP doesn't provide sequencing of the packets that the data arrives in. This means that the application program that uses UDP must be able to make sure that the entire message has arrived and is in the right order. Network applications that want to save processing time because they have very small data units to exchange (and therefore very little message reassembling to do) may prefer UDP to TCP. The Trivial File Transfer Protocol (TFTP) uses UDP instead of TCP.
UDP provides two services not provided by the IP layer. It provides port numbers to help distinguish different user requests and, optionally, a checksum capability to verify that the data arrived intact.

Thursday, August 8, 2013

Understanding Memory issues through Perfmon:Page faults



I have been using Perfmon almost daily, but never took pain to learn how to use it efficiently until I came across a situation …In this part we will discuss using perfmon to see memory bottleneck.
Before we proceed forward let us go through few definitions so that the rest of the stuff is easily understood.

Virtual memory: Its actually virtual …and from here the concept of paging comes in to picture .On a 32 bit machine its 2 gigs for user process by default ….So, if your RAM is 512 MB, the remaining stuff (I mean greater that 512 MB) that’s going to come from Virtual memory will page out to disk .SO operations worth 2 gigs will happen in VAS (VM) and as a storage RAM will be used and the moment RAM limit is exceeded …..Paging/Swapping .

Page: Committed data in VAS is written to Page tables .From there it goes to RAM or Pagefile .This data is written in to pages (in bytes) and its size is processor dependent. this page is fitted in to page frame in RAM…it is essential that , that frame must be filled with zeros before a page from disk is inserted into page frame .zeroing is essential as the page before zeroing may have information from any other process ..So when we restart Windows this zeroing activity takes place and complete by the virtual memory manager before the Windows comes up..And if there is some problem during zeroing then………….. :D …we will discuss some other time …

Page file: a space in the HDD to be used to save committed memory objects.

Reserved memory: the memory quota given to a process by the VM manager .So the process first has to consume this before the next quota is allocated …

Committed memory: The chunk from reserved memory that is actually being used by the process. Remember that whenever memory is committed the same amount of space is created on the pagefile so that if needed it can be flushed to disk.

Working Set: Physical memory assigned to a process by VM manager (or say OS).It will be always less than Private Bytes.

Page Fault : When the page needed is not found in the working set of the process but its with in the RAM (may be in some cache) its called as Soft page fault .But when the page is not at all found in the RAM , its paged out and called as Hard page fault.

So now, it’s sure that whenever there is a memory issue there will be high (hard) Page fault rate...If there is a constant high hard page fault rate it means that there is some data not found in the RAM for the working set of that process .So , it has to be fetched from the disk (which is going to be costly).And the hard page faults cause Paging .So is paging harmful ….No (we cannot avoid it ), but the excess of it is a signal that something is going wrong .Generally I have seen that keeping the page file to be equal to 1.5 times of RAM is ok ..Not bad.

In case of memory issue the counters that we need to see in Perfmon are Memory and Process...

The Sub counters for memory counter are: Page Faults/sec, Page Reads/sec, Page Writes/sec, Pages Input/sec, Pages Output/sec, Available bytes and nonpaged pool bytes.

The Sub counters for Process counter are: Page Faults/sec, working set, Private Bytes and Page File Bytes

So, % Soft page faults = ((Page fault/sec - Pages input/sec) x 100)/Page faults/sec

Now, if there are more hard page faults, there should be more pages output/sec (no of pages sent to disk to make room for the pages coming form disk due to hard page fault) since there is a limited working set and hence there has to be some space for the pages coming from the disk (hard page faults) ...Pages read/sec and pages input/sec should be almost similar but can be a bit different …So these counters can tell you the system story..One more counter that I forgot to mention is Available Bytes .Its the no. of bytes left for the process to allocate. To see how much SQL Server shares you can see Page Faults/sec and proportionate it with Total Page faults. Generally, hard page fault of 10% to 15% should be tolerated …Before, we totally blame memory let’s check the Disk performance as well...

Subtract Memory:Page reads/sec from logical disk:disk reads/sec .If the output is small (+ or -) then the memory is the bottleneck because this actually means that all the disk reading is done to find the faulting pages .Also if disk output/sec is high then you can check by finding the difference of disk output/sec and Disk write bytes/sec ÷ 4096 ßintel and fine its percentage in total Disk write bytes/sec

Similarly, you can then correlate it to SQL Server as well …..Once you are sure that memory is the bottleneck then we can proceed with the troubleshooting steps...
Next time we will try to dig into memory issues including memory leaks and also perfmon counters specific to SQL Server …

Wednesday, July 31, 2013

Web Page Rendering


Below are the step-by-step descriptions of how page get displayed in your browser when you simply enter some URL in address bar:
1.    You type an URL into address bar in your preferred browser.
2.    The browser parses the URL to find the protocol, host, port, and path.
3.    It forms a HTTP request
4.    To reach the host, it first needs to translate the human readable host into an IP number, and it does this by doing a DNS lookupon the host
5.    Then a socket needs to be opened from the user’s computer to that IP number, on the port specified (most often port 80)
6.    When a connection is open, the HTTP request is sent to the host
7.    The host forwards the request to the server software (most often Apache) configured to listen on the specified port
8.    The server inspects the request (most often only the path), and launches the server plugin needed to handle the request (corresponding to the server language you use, PHP, Java, .NET, Python?)
9.    The plugin gets access to the full request, and starts to prepare a HTTP response.
10.  To construct the response a database is (most likely) accessed. A database search is made, based on parameters in the path (or data) of the request
11.  Data from the database, together with other information the plugin decides to add, is combined into a long string of text (probablyHTML).
12.  The plugin combines that data with some meta data (in the form of HTTP headers), and sends the HTTP response back to thebrowser.
13.  The browser receives the response, and parses the HTML (which with 95% probability is broken) in the response
14.  A DOM tree is built out of the broken HTML
15.  New requests are made to the server for each new resource that is found in the HTML source (typically images, style sheets, and JavaScript files). Go back to step 3 and repeat for each resource.
16.  Stylesheets are parsed, and the rendering information in each gets attached to the matching node in the DOM tree
17.  Javascript is parsed and executed, and DOM nodes are moved and style information is updated accordingly
18.  The browser renders the page on the screen according to the DOM tree and the style information for each node
19.  You see the page on the screen 

Friday, July 19, 2013

Test Plan and Test Strategy

Test strategy:
This document is normally prepared by project manager using business requirement documents and is normally not updated frequently.

Test Plan:
This document is prepared by test lead or Senior Test engineer using SRS, use case document, product description. This is usually derived from test strategy. This document is updated with each release or build

Components of the Test Strategy document Components of the Test Plan document
Scope and Objectives Test Plan id
Business issues Introduction
Roles and responsibilities Test items
Communication and status reporting Features to be tested
Test deliverability Features not to be tested
Industry standards to follow Test techniques
Test automation and tools Testing tasks
Testing measurements and metrices Suspension criteria
Risks and mitigation Features pass or fail criteria
Defect reporting and tracking Test environment (Entry criteria, Exit criteria)
Change and configuration management Test delivarables
Training plan Staff and training needs
Responsibilities
Schedule

Wednesday, February 27, 2013

Transactional Concurrency in Load testing

Problem - How many transaction will need to run per minute if a load test  has to run for 2 hours with 5000 users, assuming average length of transaction if 5 minutes.

Solution-
Duration of load test -120 minutes
User load- 5000
Average Length of transaction- 5 minutes
No. of transaction per minute-?


No. of transaction performed by single user in 120 minute = 120 minutes / 5 minute = 24 transaction

No. of transaction performed in 2 hours by 5000 users = 5000*24 =120000 transactions.

No. of transaction per minute =No. of transaction performed during 2 hour by 5000 users/duration of two hour = 120000/120= 1000 Transaction /Minute

Sunday, January 27, 2013

LoadRunner : Save Dynamic Parameter value in Text File



I have a  value which dynamic for each iteration. I have captured that value using web_reg_save_param(correlation) function. Please any enahncement in the script is most welcome….
Action_Main_URL()
{
 char MainID; 
 int i; 
 char Length[100]; 
 long file; 
 char * filename = “c:\\Session.txt”; 

 if ((file = fopen(filename, “a+” )) == NULL) 
 { 
 lr_output_message(“Unable to create %s”, filename); 
 return -1; 
 }

 web_reg_save_param( “Cor_Session_Id”, “LB= value=’”, “RB=’”, “Ord=6″, “IgnoreRedirections=Yes”, “Search=Body”, “RelFrameId=1″, LAST );
 web_url(“Workplace”,
  ”URL=http://server/Workplace”,
  ”Resource=0″,
  ”RecContentType=text/html”,
  ”Referer=”,
  ”Snapshot=t1.inf”,
  ”Mode=HTML”,
  LAST);
 lr_start_transaction(“TS_Main_URL_Login”);
 web_reg_find(“Text=Record Search and Check-In”, “SaveCount=Value_Count”,
  LAST);
 web_submit_data(“WcmSignIn.jsp”,
  ”Action=http://server/Workplace/WcmSignIn.jsp?eventTarget=signInModule&eventName=SignIn”,
  ”Method=POST”,
  ”RecContentType=text/html”,
  ”Referer=http://server/Workplace/WcmSignIn.jsp?targetUrl=WcmDefault.jsp&targetBase=http%3A%2F%2Fserver%2FWorkplace&sessionId={Cor_Session_Id}&originIp=10.x.x.x&originPort=”,
  ”Snapshot=t2.inf”,
  ”Mode=HTML”,
  ITEMDATA,
  ”Name=targetBase”, “Value=http://server/Workplace”, ENDITEM,
  ”Name=originPort”, “Value=”, ENDITEM,
  ”Name=targetUrl”, “Value=Default.jsp”, ENDITEM,
  ”Name=encodedSessionId”, “Value=null”, ENDITEM,
  ”Name=originIp”, “Value=10.x.x.x”, ENDITEM,
  ”Name=sessionId”, “Value={Cor_Session_Id}”, ENDITEM,
  ”Name=browserTime1″, “Value=Sat Jan 1 05 EST 2011″, ENDITEM,
  ”Name=browserTime2″, “Value=Wed Jun 15 05 EDT 2011″, ENDITEM,
  ”Name=browserOffset1″, “Value=300″, ENDITEM,
  ”Name=browserOffset2″, “Value=240″, ENDITEM,
  ”Name=clientTimeZone”, “Value=”, ENDITEM,
  ”Name=appId”, “Value=Workplace”, ENDITEM,
  ”Name=userId”, “Value=userid”, ENDITEM,
  ”Name=password”, “Value=password”, ENDITEM,
  EXTRARES,
  ”Url=images/web/common/Banner.jpg”, “Referer=http://server/Workplace/HomePage.jsp?mode=reset”, ENDITEM,
  LAST);
 if (atoi(lr_eval_string(“{Value_Count}”)) > 0)
  {
  lr_output_message(“Page found successfully.”);
  }
  else
   {
   lr_error_message(“Page is not found.”);
   lr_exit( LR_EXIT_MAIN_ITERATION_AND_CONTINUE,LR_FAIL );
  return(0);
   }

 lr_end_transaction(“TS_Main_URL_Login”,LR_AUTO);
 sprintf(Length,”\n%s,”,lr_eval_string(“{Cor_Session_Id}”)); 
 i = fwrite(&Length,sizeof(Length), 1, file); 
 if ( i > 0) 
 lr_output_message(“Successfully wrote %d record”, i ); 
 fclose(file);
 return 0;
}


Tuesday, January 22, 2013

Requirement Gathering for Performance test Project

Here are the Ideal Requirements to be included while developing a Performance test plan.


• Deadlines available to complete performance testing, including the scheduled deployment date.

• Whether to use internal or external resources to perform the tests. This will largely depend on time scales and in-house expertise (or lack thereof).

• Test environment design agreed upon. Remember that the test environment should be as close an approximation of the live environment as you can achieve and will require longer to create than you estimate.

• Ensuring that a code freeze applies to the test environment within each testing cycle.

• Ensuring that the test environment will not be affected by other user activity. Nobody else should be using the test environment while performance test execution is taking place; otherwise, there is a danger that the test execution and results may be compromised.

• All performance targets identified and agreed to by appropriate business stakeholders. This means consensus from all involved and interested parties on the performance targets for the application. 

• The key application transactions identified, documented, and ready to script. Remember how vital it is to have correctly identified the key transactions to script. Otherwise, your performance testing is in danger of becoming a wasted exercise.

• Which parts of transactions (such as login or time spent on a search) should be monitored separately. This will be used in Step 3 for “checkpointing.”

• Identify the input, target, and runtime data requirements for the transactions that you  select. This critical consideration ensures that the transactions you script run correctly and that the target database is realistically populated in terms of size and content. Data is critical to performance testing. Make sure that you can create enough test data of the correct type within the time frames of your testing project. You may need to look at some form of automated data management, and don’t forget to consider data security and confidentiality.

• Performance tests identified in terms of number, type, transaction content, and virtual user deployment. You should also have decided on the think time, pacing, and injection profile for each test transaction deployment.

• Identify and document server, application server, and network KPIs. Remember that you must monitor the application landscape as comprehensively as possible to ensure that you have the necessary information available to identify and resolve any problems that occur.

• Identify the deliverables from the performance test in terms of a report on the test’s outcome versus the agreed performance targets. It’s a good practice to produce a document template that can be used for this purpose.
• A procedure is defined for submission of performance defects discovered during testing cycles to the development or application vendor. This is an important consideration that is often overlooked. What happens if, despite your best efforts, you find major application, related problems? You need to build contingency into your test plan to accommodate this possibility. There may also be the added complexity of involving offshore resources in the defect submission process. If your plan is to carry out the performance testing in-house then you will also need to address the following points, relating to the testing team.


Thursday, January 17, 2013

How to Define Pacing in Load Testing

 Pacing Calculation :-



 D = Duration of the test(test window/time frame)
 B = Baseline time(total time taken by 1 Vu to complete 1 whole iteration)

 T = Total amount of Think time in the script

 I = Expected/Target iteration

 R = Residual time of the test window.

 R = ( D - (T + B)*I)

 P = Pacing interval

 Dividing the residual time by target iteration gives pacing interval

Hence:
 P = R/I 



D is pacing time.
(T + B)*I represents the duration of a scenario
and P is the waiting time before the next scenario

Friday, December 14, 2012

Why response time of a page does not equal the sum of its requests


The response time for a page typically differs from the sum of its requests. This does not mean that your data is incorrect. The difference can be caused by concurrent requests, page connection times, inter-request delays, and custom code within a page.
The most common reason for the sum of the individual request times within a page to exceed the total page response time is that requests are often sent concurrently (in parallel) to a server. Thus some of the individual request response times overlap so the sum of the request response times would exceed the page response time.
Additionally, the page response time can exceed the sum of the individual request response times within the page for the following reasons:
  • The individual request response times do not include time to establish connections but the page response time does include the connection request time.
  • Inter-request delays are not reflected in the individual request response time but are reflected in the page response time.
  • Custom code placed within a page is executed serially (after waiting for all previous individual requests to complete) and thus contributes to the page response time. It does not affect individual request response times. However, we recommend that you place custom code outside of a page, where it will not affect page response time.

Saturday, December 8, 2012

Performance Testing Estimation Preparation

It depends of which estimation techniue you are using...if it is WBS then you will have to break all the performance testing activities in smaller parts then using your prior experience you can estimate no of days for each activities. Also take some time for each activity in spare so that you can get time in case of any environmental or deploymental delay or issue. Incase of WBS following activities can be considered: 

A. Planning 
1. Understanding of application 
2. Identifing of NFR 
3. Finilazing the workload model 
4. setup of test environment and tools& monitors 
5. Preperation of Test plan 

B. Preperation 
1. Creation & validation of Test scripts 
2. Creation of Test Data 
3. Creation of business scenarios 
4. Getting approval 

C. Execution 
1.Run a dummy test 
2. Baseline test 
3. Upgrade or tune the environment (if needed) 
4. baseline test2 
5. final performance run 
6. Analysis 
7. Final performance run2 
8. Benchmarking etc.. 

D. Reporting 
1. Creation of performance test report 
2. Review with seniors or peers 
3. Update the report 
4. Publish the final report. 
5. Getting signoff 

Thursday, November 29, 2012

Challenges in Agile Testing




Every software development lifecycle model, from sequential to spiral to incremental to Agile, has testing implications. Some of these implications ease the testing process and some of these implications challenge testing.

A blended testing strategy consists of three types of test strategies:

• Analytical risk-based testing;
• Automated regression testing;
• Reactive testing (also referred to as dynamic
testing).

The blended testing strategy aligns well with Scrum and other agile methodologies.
In some cases, these strategies mitigate the testing risks and reduce the testing challenges associated with these methodologies.  
However, it does not resolve all of the risks and challenges, few of the challenges faced and the best approach to mitigate them have been discussed below:


Dealing with the Volume and Speed of Change

“Welcome changing requirements” is considered as one of the principles of agile development,
Many testing strategies, especially analytical requirements-based testing, become quite inefficient in such situations. 
However, risk-based testing accommodates change, since we can always add risks, remove risks, change risks, and adjust the level of risk.If test execution is underway, we can adjust our plan for the remaining period based on this new view of quality risk.

The reactive testing, not requiring much documentation, is also quite resilient in the face of change.

However, challenges arising from change in the definition of the product and its correct behavior, when the test team is not kept informed of these changes, or when the rate of change is very high, can impose inefficiencies on the development, execution, and maintenance of tests.

Remaining Effective during Very Short Iterations

Agile methodologies like Scrum are less formal and faster moving “sprint”’. These methodologies use short, fast-paced iterations, further squeezing the test
team’s ability to develop and maintain test systems, compounding the effects of change.

Testing strategies that include an automation element have proven particularly/sensitive to this challenge.

The risk-based element of the recommended strategy can help.
Risk-based testing focuses on the important areas of test coverage, and de-emphasizes or even cuts less important areas, relieving some of the pressure created by the short iterations. This ability to focus proves especially helpful for test teams also under tight resources constraints. Test teams in an agile world should develop, maintain, and execute tests in risk priority order.
Using risk priority to sequence development and maintenance efforts allows the test team to have the most important tests ready at the beginning of each sprint’s test execution period.

Receiving Code after Inconsistent and Often Inadequate Unit Testing

The short test execution periods on Agile sprints, compared to sequential projects, means that the degree of damage caused by one or two days of test progress blockage due to highly buggy code is higher than in a sequential project.
Delivery of unstable, buggy code will undermine one of the key benefits of the risk-based
testing portion of the recommended strategy, which is the discovery of the most important
defects early in the test execution period.
It also inevitably leads to a large degree of code churn during testing, since so much must change to fix the bugs.
The amount of change can ultimately outstrip even the ability of the best automated regression test system to keep up, which would then lead to lower defect detection effectiveness for the test team.

Managing the Increased Regression Risk

Agile methodology advocates emphasize good automated unit testing
in part to manage the regression risk inherent in such churn.
However, good unit testing has limited defect removal effectiveness.
Therefore, we need effective regression testing at the system test level (which has a higher level of defect detection effectiveness).
By combining risk-based testing with the automated regression testing, test teams can effectively manage the increased regression risk.

Making Do with Poor, Changing, and Missing Test Oracles

Agile methodologies de-value written documentation. Special scorn is reserved for specifications.
For example, the Agile Manifesto suggests people should value “working software over comprehensive documentation.”
This creates real challenges for a test team.Testers use requirements specifications and other documents as test oracles; i.e., as the means to determine correct behavior under a given test condition.
Testers in Agile situations are often given documents with insufficient detail, or, in some cases, given no such documents at all.No known test strategy can resolve this challenge. Resolving the challenge requires change management.
Further, the inability to determine precisely whether a test failed affects both the efficiency of the testing and the defect detection effectiveness.
When testers spend time isolating situations that the project team ultimately chooses to define as correct behavior, that takes away time they could have spent finding and reporting real bugs.
These bugs create subsequent problems customers, users, and technical support staff, and distractions for developers and test teams.
Further, the situation creates frustration for the testers that reduces their morale and, consequently, their effectiveness.
Testers want to produce valid information. When much of the information they produce – in the form of rejected bugs reports – ends up in the figurative wastebasket of the project that tends to make people wonder why they bother.
It’s important to realize that this reduction in test effectiveness, efficiency, and morale is a
potential side-effect of agile methodologies. Bad problems can get much worse when the test team is held accountable for outcomes beyond their control.

Holding to Arbitrary Sprint Durations

Some of our clients following agile methodologies like Scrum tend to ritualize some of
the rules of the process. The time deadlines for sprints seem particularly subject to this ritualization.
So, on the last Friday of the sprint, with development ending late for the sprint, the arbitrary deadline remains intact at the expense of the test team’s weekend.
Fully resolving this challenge requires team and management maturity. When people habitually and systematically over-commit,
If fixing the software estimation problems cannot occur, risk-based testing helps the test team deal with systematic and constant over-commitment.
To start with, when the test team is time-crunched over and over again at sprint’s end, the test team should accept that the project team’s priorities are schedule-driven, not quality-driven.
The test team should revise the risk analysis approach to institute an across the-
Board  reduction in the extent of testing assigned to each quality risk items during risk
analysis for subsequent projects.
That way, at least the test team won’t over-commit.
In some cases, in spite of reducing the scope of testing, the test team still can’t execute all the tests in the available time at the end of a sprint. If so, rather than ruining their weekend to run every test, the test team can select the most important tests using the risk priority number.
Less important tests can slip into the next sprint.

Conclusion
The test strategies recommended support the stated goals of Agile methodologies.

Risk-based testing supports increased quality, since it focuses testing on high-risk
areas where testing can significantly reduce the risk. Risk-based testing supports increased productivity, since it reduces or eliminates testing where the quality risk is lower. Risk based testing supports flexibility, since it allows regular revision of the quality risk items which re-aligns the remaining testing with the new risks and their new levels of risk.
Automated regression testing helps to contain the regression risks associated with Agile methodologies, allowing a higher rate of change.

Reactive testing allows testers to explore various aspects of the system that risk-based testing and automated regression testing together might miss.