Saturday, April 4, 2009

How to implement Lower Thread Priorities?

If you have a rarely used feature that uses a lot of CPU resources, you can lower the priority of the thread that handles requests for that feature. Use the setPriority() method of java.lang.Thread to temporarily lower the thread priority. This will result in higher latency for users of that expensive feature, but prevents that feature from hurting performance of other users

How to address System Resource Bottlenecks?

System Resource Bottlenecks: If your site has not maxed out either CPU utilization, database server utilization, or I/O subsystem, the problem may result from synchronized access to one of your system's resources (disk, network, database, etc.). This situation occurs when you access this resource from within a synchronized method in Java. All other requests wait for this monitor lock while you do the I/O, thus wasting both CPU and I/O resources.

The only ways around this problems are to recode the Java (the right solution) or add more App Server instances (the wrong solution).

How to check for Thread Context Switching Problems?

Thread Context Switching Problems:-
Check how many simultaneous requests are typically being handled when you have a large number of clients trying to access App Server. When the site is under load, go to the App Server administration page, and see how many handlers are active.

You can also reduce overhead from thread context switching by making sure you have at least one CPU for each process involved in handling the majority of requests:
  • One CPU for your HTTP server,
  • One for App Server,
  • One for the database server.

Note:- The assumption here is that, all the servers (HTTP, Applicaion and Database servers) are running on a multiprocessor (more than 3 processors) system.

Typically, these context switches can be overcome by increasing the parallelism in your site (increasing the number of Server handler threads).

How to locate Performance Bottlenecks at High CPU Utilization in middleware or Application Server?

Bottlenecks at High CPU Utilization:-
If your site CPU utilization is close to 100%, you can use a tool like OptimizeIt or KL Group's JProbe Profiler to help determine slow points of your code. See Using OptimizeIt .

In some instances, OptimizeIt cannot handle large sites running under load. If so, another way to identify deadlocks and bottlenecks is to get your JVM to dump out stack traces while your system is under load.

How to address Performance Bottlenecks for Network-Limited Problems?

Checking for Network-Limited Problems: One way to identify network-limited performance problems is by getting your JVM to dump out stack traces while your system is under load. You can tell if your system is network limited because your thread dump will show lots of threads waiting in socket reads or writes. See Getting Java VM Dumps and Analyzing Java VM Dumps

Some ways to address network-limited problems include:
  • Reduce the size of your HTML files by limiting comments and white space or redesigning the content of especially large pages.
  • Increase the number of request handling threads. This won't improve the latency experienced by a user who requests a large file, but it will improve total throughput.
  • Get a faster network connection.
  • Locate and correct network bottlenecks

How to check for Disk I/O Bottlenecks in AppServer?

Checking for Disk I/O Bottlenecks: Make sure that your JVM really is waiting for file I/O, not paging activity. Check for paging with your operating system's monitoring tools.

How to locate Performance Bottlenecks for Database?

Checking for Database Bottlenecks: If your site has low CPU utilization at maximum throughput, check whether the database is limiting performance.
  • Get a JVM thread dump (see Getting Java VM Dumps ) and examine it to see if there are many threads waiting for a response from the database (see Analyzing Java VM Dumps ).
  • Check the CPU utilization and disk I/O utilization of your database server.
  • Check the network bandwidth between the App server and the database server.

How to locate Performance Bottlenecks at Low CPU Utilization?

Bottlenecks at Low CPU Utilization: If your site has low CPU utilization when it is achieving maximum throughput, the bottleneck is likely either:
  • Database limited (if database output is maxed out); see Checking for Database Bottlenecks
  • Disk I/O limited (if I/O output is maxed out); see Checking for Disk I/O Bottlenecks
  • Network I/O limited (if I/O output is maxed out); see Checking for Network-Limited Problems
  • Database or I/O activity in a synchronized method (if database or I/O output is not maxed out); see System Resource Bottlenecks

If your site is in this situation, CPU profiling tools like OptimizeIt are not that useful. Thread dumps taken while the system is under load can give you better information.

How to locate Performance Bottlenecks?

Performance Bottlenecks can be identified in the following ways:-
  • Bottlenecks at Low CPU Utilization
  • Checking for Database Bottlenecks
  • Checking for Disk I/O Bottlenecks
  • Checking for Network-Limited Problems
  • Bottlenecks at High CPU Utilization
  • Thread Context Switching Problems
  • System Resource Bottlenecks
  • Lower Thread Priorities

Note:- For detailed informationa about above mentioned bottlenecks visit our individual questions?

What is a cookie? What are the steps need to be taken care during recording?

Cookie: A cookie is simply a piece of text stored on a client computer by a web application.
  • Persistent cookies. Also called a permanent cookie, or a stored cookie, a cookie that is stored on a user’s hard drive until it expires (persistent cookies are set with expiration dates) or until the user deletes the cookie. Persistent cookies are used to collect identifying information about the user, such as Web surfing behavior or user preferences for a specific Web site
  • Non-persistent cookies (also known as session cookies). Used by Commerce Server to track authenticated users who visit your site? When the session ends, the cookies are deleted. Non-persistent cookies store MSCSAuth tickets.

Both persistent cookies and non-persistent cookies can be encrypted. The non-persistent cookies contain the fields like User ID , Time of last login, Time Window.

Before recording all the persistent cookies need to be removed from the respective browsers.

What is document cache? How does document cache impacts the peroformance of a webpage?

Document Cache: Document cache is a location on the user’s computer where a web browser temporarily stores downloaded web pages. This is a way to speed up page downloading times and to reduce traffic on the network.
  • Using the cache saves time. However, documents stored persistently will become outdated if the original documents on the web sever changes. To guard against this, web browser checks whether a document in the cache is an up-to-date copy of the original on the server. This is a user specified option, and the most popular setting for web browser today is set to check once per session whether a document on the server has changed since the user last viewed it.
  • A load testing tool must emulate web browser’s document cache.

What is page redirection? How does page redirection works in load testing tools?

Redirections: Redirection refers to the process by which a page is sent to the browser with the sole purpose of forwarding the user to another page or server. This technique is usually used to handle load-balancing or dynamic page generation, or simply to transfer users from an old server to a new one.
  • Browsers usually do not follow redirections more than five times, since a high number of redirections could indicate a infinite loop.

A redirection from one page to another can occur in various way:

  • Location field: The header of the HTTP response may contain a “location” or a “refresh” field that orders the browser to redirect the user to a different page
  • Refresh Header: A web page may invoke a JavaScript the leads the user to another page
  • Refresh Tag: A web page may contain an HTML tag that indicates a redirection

Load testing tools must be able to emulate redirection as it is frequently used technique in web applications.

What is Browser thread? How does Browser threads impact the performance?

Browser threads: A thread is a path of execution through an application. In the case of web browsers, this path consists of sending a request, receiving the response and displaying the object. Each thread operates independently.
  • Single-threaded mode is used when a web browser executes a Java script that communicates continually with a web server, or more generally, when a client application other than a web browser is employed.
  • Load testing tools need to have the ability to accurately emulate web browsers in both single and multi threaded modes in order to apply realistic workloads to the web applications being tested.

How to calculate sessions per hour? - Little's Law

Calculating Sessions per hour: For this discussion, we will be focusing on a session as the total time for the user group to finish one complete set of transactions. We may wish to know the number sessions that will be completed for any given number of virtual users.
  • Example 1:- If a baseline test shows that a User Type takes a total of 120 seconds for a session, then in an hour long steady state test this User Type should be able to complete 3600 / 120 = 30 sessions per hour. Twenty of these users will complete 20 x 30 = 600 of these session in an hour. In other cases, we have a set number of sessions we want to complete during the test and want to determine the number of virtual users to start.
  • Example 2:Using the same conditions in our first example, if our target session rate for sessions per hour is 500, then 500 x 30 = 16.7 or 17 virtual users. A formula called Little's Law states this calculation of VirtualUsers in slightly different terms.
  • Using Little's Law with Example 2:
    wV.U. = R x D where R = Transaction Rate and D = Duration of the Session
    If our target rate is 500 sessions per hour (.139 sessions/sec) and our duration is 120 seconds, then Virtual Users = .139 x 120 = 16.7 or 17 virtual users.

how can you effectively test the performance of your Web site from locations that are thousands of miles away?

Possible solutions include:-
  • Using the services of a third-party company that specializes in testing a Web site from different locations around the world
  • Utilizing the different physical locations (branches) that your organization may already possess, coordinating the execution of your test plan with coworkers at the offices
  • Using a modem to dial ISP telephone numbers in different cities and factoring out the additional time for the cross-country modem connection
  • Buy an “around the world” airplane ticket for one or more of the Web site’s testers

How does user geographic locations impacts performance of the website?

User Geographic Locations: Due to network topologies, response times for Web sites vary around the country and around the world. Internet response times can vary from city to city depending on the time of day, the geographic distance between the client and the host Web site, and the local network capacities at the client-side.

Remote performance testing can become particularly important if mirror sites are to be strategically positioned in order to improve response times for distant locations.

What is background noise in performance testing?

Background Noise: When designing a load to test the performance of a Web site or application, consider what additional activities need to be added to a test environment to accurately reflect the performance degradation caused by “background noise.”

Background noise is created by other applications running that will also be running on the production servers once the application under test moves into production, and other network traffic that will consume network bandwidth and possibly increase the collision rate of the data packets being transmitted over the LAN and/or WAN.

What is Site Abandonment?

In real life, some users may be able to select their next page before the previous page has been completely downloaded. The user is not waiting till the previous page has been completely loaded. This is nothing but Site Abandonment.

Unfortunately basic load / performance test scripts/tools assume that a client will wait until a Web page has been completely downloaded before requesting the subsequent page

Why Functional Failures happen in Highly Stressed Applications?

Load and stress testing are generally thought of in terms of system performance degradation. However, applications running under extreme load conditions can actually experience functional failures that are not manifested under "normal" operating conditions. These can be application crashes, exposing security vulnerabilities, or unexpected application results (e.g., intermixing transaction data due to buffer overflows under high load).

Example:- In real time, when the stock market crashes(in India), most of the Security / Stock trading portal systems will not be responding or you can crashed in the application due to heavy user load or stress on the application.

What are the scalability considerations? What is Horizontal Scalability and Vertical Scalability?

Scalability consideration are...

  • Adding new applications or customers to the system.
  • Horizontal Scalability -- AKA "rack density". Throw hardware at the problem. Typically easier and affordable than most forms of vertical scalability.
  • Vertical Scalability -- The ability to increase the capacity of existing hardware or software by adding resources - for example, adding processing power to a server to make it faster. nHardware/software scalability metrics Here are some metrics to measure the levels of resource saturation:
    * CPU utilization — Number of users supported versus CPU utilization
    * Memory — Number of users supported versus available memory

* Disk I/O — Number of users supported versus number of disks

* Network I/O — Number of users supported versus wire speed of network

What are the dimensions of scalability?

Dimensions of Scalability:
Scalability is often qualified along specific ranges of factors, among which are the ability to increase:
  • Total number of users
  • Number of concurrent users
  • Number of user's locations
  • The extent and size of the data store
  • Transaction volume
  • Output volume
  • Response time

What is scalability?

Scalability:- Scalability is determined by the number of simultaneous clients served over a given period of time with a limited delay time
  • The key determinant of scalability is Transaction Time
  • Transaction Time doesn't mean good scalability - in fact it's the antithesis of it.

Example:-

  • Case - 1 :- The response time of a page for 100 users is 1 sec, 200 users 2 sec and 500 users is 5 Sec
  • Case - 2:- The response time of a page for 100 users is 4 sec, 200 users 4.5 sec and 500 users is 5 Sec

Now analyze Case - 1 and Case - 2. Which is scalable?

The answer is Case - 2. The reason is response times in Case - 1 are growing as we increase the number if users. Whereas in Case - 2 the response times are some what stable even if we increase the number of users. Now we will say the Case - 2 is scalable.

What are the factors causes for slow download times?

There are two main factors create slow download times: Large web page sizes and slow server performance.


  • Pages: Too Many Bytes :- bigger the page size, slow the response time is. Compare loading google and yahoo websites and measure the response time. Which home page takes longer time to load. yahoo home page is more than 159KB with lots of images and google home page is not more than 10KB.

  • Slow Servers:- If the performance of any server is slow within the architecture of the application, that server becomes a bottleneck. And it leads to high response time. That means poor performance.

The standard guidelines for response times are:



  • 0.1 second (one tenth of a second). Ideal response time. The user doesn't sense any interruption.

  • 1 second. Highest acceptable response time. Download times above 1 second interrupt the user experience.

  • 10 seconds. Unacceptable response time. The user experience is interrupted at an alarming high rate and the user is likely to leave the site or system.

These numbers are highly useful when planning server capacity.

What is stability testing?

- Stability: A stability test is designed to determine whether a web application will remain serviceable / stable over an extended time span.

Outcomes of this testing is :
  • To determine memory leaks on middleware or application servers
  • To find out the cursor leaks on the database
  • To find out connection leaks on the database
  • To find out the response time degradation with the data growing on the database etc.

What are the goals of performance testing?

Performance Goals are:

  • Stability
  • Response time
  • Scalability
  • Errors

Performance Testing Life Cycle

Performance Testing Life is best described in the below chart.

Performance Testing in Modern Development Life Cycle

Each phase in Software Development Life Cycle (SDLC) has a component of Performance Testing Life Cycle. Performance Testing Life Cycle consists of
  • Analyzing service level agreement
  • Defining performance requirements
  • Creating test design,
  • Building performance test scripts, how these test scripts are executed
  • And finally the analysis phase.

What kind of questions Performance, Load and Stress testing answers?

Performance, load and stress testing answers the questions like:
  • Can my website support 1,000 hits/second? If so, for how long?
  • Can my e-commerce application handle 500 users searching for products and 250 users adding items to their shopping carts simultaneously?
  • What happens to application performance as the backend database gets larger and larger?

Why load testing is important?

Load testing is important because...
  • Increase uptime of mission-critical Internet systems.
  • Avoid project failures by predicting site behavior under large user loads
  • Measure and monitor performance of your e-business infrastructure.
  • Protect IT investments by predicting scalability and performance.

What is the criteria to select a performance-testing tool?

There are many criteria's (related to your organization, your project / product and protocol) need to be fulifilled by the tool. Some the criterias are listed below...
  • Support for your application environment
  • Intuitive test case design and execution
  • Accurate emulation of real users
  • Power and scalability to generate required system load levels
  • Accurate error detection and performance measurements
  • Powerful root cause analysis capabilities

Where exactly the Performance Testing stands in Software Development Life Cycle?

There are many levels of testings in the testing life cycle. The below ima
ge gives you an insight about where exactly performance testing stands in Testing life cycle.


Constraints of Performance Testing

The major Constraints of Performance Testing :
  • Performance Testing is a complex and time consuming activity.
  • The testing process should start from the requirements collection phase itself.
  • Performance Testing requires simulating several hundred concurrent users. This requires automated tools that are expensive.
  • A proper environment like bandwidth, system configuration, and concurrent users hinders in providing adequate performance results.
  • Production environment cannot be simulated as it requires investments. A subdued environment may not produce the relevant results.
  • Skill set to plan and conduct Performance Testing is not adequately available. It is a late activity, and duration available for testing is not adequate. However, testing the system for an optimal performance is a challenge and an opportunity.

Benefits from Performance Testing

There are many benifits from the performance testing. Some of them are listed below...
  • Improved quality from a user’s perspective
  • Reduced cost of change
  • Reduced system costs
  • Increased profits
  • Early identification of major application defects and architectural issues
  • Guaranteed customer satisfaction
  • Clarity on resource utilization
  • Performance Testing also removes many myths associated with the users and builds confidence

Comparison between Functionality Testing and Performance Testing

Functional Testing Vs Performance Testing
  • Functional Testing: Functional testing is conducted to verify the correctness of the operations of the software. The features and functions are tested before performance testing. The purpose is to verify that the internal operations of the product are working according to desired specifications. Functional testing typically tests accuracy of the application and how it behaves with different operating systems.

  • Performance Testing: Performance Testing is designed to test the overall performance of the system at high load and stress conditions. Performance Testing occurs through out the software development life cycle to isolate performance related constraints. Even at unit level, the performance of the individual module may be assessed as the internal logic of software that is being tested.

How network speed impacts the performance?

Network Speed Vs Performance:


  • Network speed and performance are proportional to each other. As the network speed increases the page performance will also improves.

Network Speed Vs Response Time:


  • Network speed and response time of a page are inversely proportional. As the network speed increases the response time decreases (means performance of the page is better).

Here are some of the examples:


  • Expected load time against modem speed









  • Monthly loss from slow page loading



Why do we need to go for Performance Testing?

The need for speed is a key factor on the Internet. Whether users are on a high speed connection or a low speed dial up modem, everyone on the Internet expects speed. Most of the research reports justify the fact that speed alone is the main factor accessing the Web site.

Segment wise business loss due to performance of the websites. The below numbers are very old. But these number are kept just for reference.


How users react on poor performance?

Users will be distracted from the site, if the performance is poor.

Performance Testing Types

Performance Testing types are:
  • load testing
  • stress testing
  • endurance testing
  • spike testing

- Load Testing
This is the simplest form of performance testing. A load test is usually conducted to understand the behavior of the application under a specific expected load. This load can be the expected concurrent number of users on the application performing a specific number of transaction within the set duration. This test will give out the response times of all the important business critical transactions. If the database, application server, etc are also monitored, then this simple test can itself point towards the bottleneck in the application.

- Stress Testing
This testing is normally used to break the application. Double the number of users are added to the application and the test is run again until the application breaks down. This kind of test is done to determine the application's robustness in times of extreme load and helps application administrators to determine if the application will perform sufficiently if the current load goes well above the expected load.

- Endurance Testing (Soak Testing)
This test is usually done to determine if the application can sustain the continuous expected load. Generally this test is done to determine if there are any memory leaks in the application.

- Spike Testing
Spike testing, as the name suggests is done by spiking the number of users and understanding the behavior of the application whether it will go down or will it be able to handle dramatic changes in load.

What is Performance Testing?

Purpose:
  • To demonstrate that the systems meets performance criteria.
  • To compare two systems to find which performs better.
  • To measure what parts of the system or workload cause the system to perform badly
Performance of a system is generally measured in terms of response time for the user activity. To illustrate, a customer likes to withdraw money from an Automated Teller Machine (ATM) counter of a specific bank. Customer inserts debit/credit card and waits for the response. If the system takes more than 5 minutes (say) to deliver the cash, customer may not appreciate the system. In this situation, though, the system is
functioning (delivering cash) according to requirements. It fails in terms of performance (takes more than 5 minutes to complete the transaction).