Wednesday, December 11, 2013

Correlation? What’s that?


Correlation? What’s that?

If you think correlation has something to do with the fit of data points to a function curve on a graph, and the word has no meaning to you in the context of LoadRunner then this document is for you. It explains what correlation in LoadRunner is, why you have to do it, how to do it, and what to do when it goes wrong. If this is the first time that you have used LoadRunner, or if you have been using it a little but are not a guru, then read on.



Introduction

LoadRunner when recording a script simply listens to the client (browser) talking to the server (web server) and writes it all down. The complete transcript of everything that was said, the dates/time, content, requests and replies can be found in the Recording Log. (View-> Output Window-> Recording Log) The script is sort of an easier to read version of this. The main difference is that the script only contains the client’s communication.

If you imagine that LoadRunner is an impersonator pretending to be the client (browser) the script is LoadRunner’s note that tells it what to say to the server to successfully fool it. We want the server to believe that LoadRunner is a real client, and so send it the information requested.

This script has the hard coded information of the original conversation (Browser session) that occurred between the client and server. This hard coded information may not be enough to fool the server during replay however. It may have to be correlated.

What is correlation?

Correlation is where the script is modified so that some of the hard coded values in the script are no longer hard coded. Rather than have LoadRunner send the original value to the server, we may need to send different values.

For example, the original recorded script may have included the server sending the client a session identification number. Something to identify the client during that particular session. This session ID was hard coded into the script during recording.

During replay, the server will send LoadRunner a new session ID. We need to capture this value, and incorporate it into the script so we can send it back to the server to correctly identify ourselves for this new session. If we leave the script unmodified, we will send the old hard coded session ID to the server. The server will look at it and think it invalid, or unknown, and so will not send us the pages we have requested. LoadRunner will not have successfully fooled the server into believing it is a client.

Correlation is the capturing of dynamic values passed from the server to the client and back. We save this captured value into a LoadRunner parameter, and then use this parameter in the script in place of the original value. During replay, LoadRunner will now listen to what the server sends to it, and when it makes requests of the server, send this new, valid value back to the server. Thus fooling the server into believing it is talking to a real client.

Why do I have to correlate?

If you try to replay a script without correlating first, then most likely the script will fail. The requests it sends to the server will not be replied to. Either the session ID is invalid, so the server won’t allow you into the site, or it won’t allow you to create new records because they are the same as existing ones, or the server won’t understand your request because it isn’t what it is expecting.

Any value which changes every time you connect to the server is a candidate for correlation. A correlated script will send the server the information it is looking for, and so allow the script to replay. This will allow many Vusers to replay the script many times, and so place load on your server.


What errors mean I have to correlate?

There are no specific errors that are associated with correlation, but there are errors that could be caused because a value hasn’t been correlated. For example, a session ID If an invalid session ID is sent to a web server, how that server responds depends on the implementation of that server. It might send a page specifically stating the Session ID is invalid and ask you to log in again. It might send an HTTP 404 Page not found error because the requesting user didn’t have permissions for the specified page, and so the server couldn’t find the page.

In general any error message returned from the server after LoadRunner makes a request that complains about permissions can point to a hard coded value that needs to be correlated.


The tools (functions) used to correlate.

In LoadRunner 7.X there four functions that you can use for correlation. A list of them, along with documentation and examples can be found in the on-line documentation. From VuGen, go to Help-> Function reference-> Contents-> Web and Wireless Vuser Functions-> Correlation Functions.

The first two functions are essentially the same, and I will talk about then together. The third function, the web_save_reg_param function differs in implementation, and the parameters it takes, but does the same job, and is used in much the same way. The last function is associated with the first two, and isn’t directly a correlation function, but rather a LoadRunner setting. It will be talked about later in a different section.

Web_create_html_param :-

This is the standard correlation function in LoadRunner 6.X and 7.X. This function takes three parameters.

web_create_html_param (“Parameter Name”, “Left Boundary”, “Right Boundary”);

Each of these parameters is a pointer to a string. That means that if they are entered as literal text, they need to be enclosed in “quotes“. Each parameter is separated by a comma.

Parameter Name: - This is the name of the parameter, or place holder variable that LoadRunner will save the captured value into. After successfully capturing the value, the parameter name is used in the script in place of the original value. LoadRunner will identify the parameter / placeholder, and substitute the captured value for the placeholder during replay. This name should have no spaces, but apart from that limitation, it is entirely up to you what name you give.

Left Boundary:- This is where we tell LoadRunner how to find the dynamic value that we are looking for. In the Left Boundary we specify the text that will appear to the left of the changing value.

Right Boundary:- This is where we tell LoadRunner how to identify the end of the dynamic value we are looking for. Here we place the text that will appear after the value we are looking for.

web_create_html_param_ex

web_create_html_param_ex ( “Parameter Name”, “Left Boundary”, “Right Boundary”, “Instance”);

This function is the same as the web_create_html_param function, except it doesn’t look for the first instance of the boundaries, but rather the nth instance of those boundaries. The first three parameters are the same, name, left, right, the last parameter is a pointer to a string, so it must be enclosed in double quotes. It is the number of the occurrence. If you place the number one here (i.e. “1”) then the function behaves exactly as the web_create_html_param function. It looks for the first occurrence. If you put the number three here (i.e. “3”) it will look for the 3rd occurrence of the left and right boundaries, and place what appears in between into the parameter.

web_reg_save_param

web_reg_save_param ( “Parameter Name” , <List of Attributes>, LAST );

The first thing to note about this function as different from the web_create_html_param functions is that the number of parameters it takes can vary. The first one is still the name, but after that there are different attributes that can be used. These attributes can appear in any order because they contain within them what they are. For example, the attribute to identify the left boundary is “LB= followed by the text of the left boundary. I won’t be talking about all of the options for this function, they are listed in the documentation. Please have a look at it. (Help-> Function Reference)

The first parameter is the name, then the list of attributes or parameters, then the keyword LAST. This identifies the end of the function. The keyword is not enclosed in quotes, all parameters are. All parameters and keywords are separated by commas.


Identifying values to correlate.

So we have the tools, and we know why we need to use them, but how do we know what to use them on? What values in the script need to be correlated. The simplest answer is, “Any value that changes between sessions required for the script to replay.”

A hypothetical example. We are logging onto a web site. When we send the server our user name and password, it replies to us with a session ID that is good for that session. The session ID needs to be correlated for replay. We need to capture this value during replay to use in the script in place of the hard coded value.

To identify values to correlate, record the script, and save it. Open a new script, and record the same actions, and business process again. As much as possible, during recording, enter the same values in both scripts. For example, user ID, password, and fields and edit selections. Save the second script, and then run it with Extended log. (Vuser-> Run time settings-> Log-> Extended log. Check all three options)

Go to tools-> Compare with Vuser, and choose the first recorded script. WinDiff will open and display the two scripts side by side. Lines with differences in them will be highlighted in Yellow. Differences within the line, will be in red.


If WinDiff gives an error here, dismiss the error, WinDiff will be minimized in the task bar. Right click on it. Choose restore. Then go to File-> Select Files/Directories, and manually select the action sections for the two scripts.

Differences like "lr_think_time" can be ignored. They are load runner pacing functions, and don’t represent data sent to the server.

Locate the first difference and take note of it and search the script open in VuGen for that difference. That is the original value hard coded into the script that was different in the second script. Highlight it, and copy it.


Go to the Recording log, and place your cursor at the top. Hit Control F (Ctrl+F) to do a search and paste in the original value. We are looking for the first occurrence of this value in the recording log. If you don’t find the value in the recording log, check you are looking in the right scripts recording log. Remember you have two almost identical scripts here.

If you find the value, scroll up in the log, and make sure the value was sent as part of a response from the server. The first header you come across while looking up the script should be preference with a receiving response. This indicates that the value was sent by the server to the client. If the value first appears as part of a sending request, then the value originated on the client side, and doesn’t need to be correlated, but rather parameterized. That is a different topic all together. The response will have a comment before it that looks like this

*** [tid=640    Action1           2] Receiving response ( 10/8/2001 12:10:26 )


So, we have a value that is different between subsequent recordings, it was sent from the server to the client. This value most likely needs to be correlated. If the value you were looking for doesn’t meet these criteria,

Different between recordings
Originated first on the server and sent to the client

It probably doesn’t need to be correlated.


Now that we know Why and What, How do we parameterize?

Step 1.
After confirming that the first occurrence was part of a received response from the server, we need to now figure out where to place the web_create_html_param( ) function. The web_create_html_param statement needs to go immediately before the request that fetched the dynamic value from the server. In order to find this request or URL in the script, we need to replay the script once with extended log and all the three options (In Vuser->Runtime Settings->Log) turned on.

In the recording log, pick up the text that is before the dynamic value. This text should remain constant no matter how many times you replay the script and highlight it and copy it. This is the text that will identify to LoadRunner where to find the start of the value we are capturing.


Now, go to the execution log and search for the text that you just copied from the recording log.


You should see a corresponding Action1.c() at the beginning of that line with a number in the brackets. That is the number of the line the script where you need to put the web_create_html_param( ) function. The function should go right above that line in the script.


So, add a couple of blank lines to your script before the function at that line, and then type in web_create_html_param(“UserSession”   but give it a name that means more to you than UserSession.


Step 2.
Go back to the execution log and highlight the text to the left of the dynamic value and copy it. This should be some of the same text we searched for in the Execution log.

The amount of text you highlight should be sufficient so that it is unique in this reply from the server. I would suggest copying as much as possible without copying any special characters. These show in the execution log as black squares, and the actual character they represent is uncertain. After selecting a boundary, go to the top of the Servers reply, and hit Ctrl+F and do a search for that boundary. You want to make certain what you have selected is the first occurrence in the servers reply. If it isn’t select more text to make it unique, or consider using the web_create_html_param_ex function or the ORD parameter or the web_reg_save_param function.

Once you have finalized the static text that represents the left boundary, copy it into the web_create_html_param (or web_reg_save_param) statement. If it contains any carriage returns, place it all on one line. If there are any “ in the text, place the escape character before it so LoadRunner doesn’t incorrectly think it is the end of the parameter, but rather a character to search for. For example, if the Left boundary was 'input type=hidden name=userSession value=' without the single quotes and we are using the web_create_html_param statement, then the function we have so far would be

Web_create_html_param(“UserSession”, “input type=hidden name=userSession value=”,

Step 3.
We are now going to tell LoadRunner how to identify the end of the value we are trying to capture. That is the right boundary of what we are looking for. Again look in the execution log and copy the static text that appears to the right of the dynamic value we are looking for. For example, lets say the execution log contained the following

… userSession value=75893.0884568651DQADHfApHDHfcDtccpfAttcf>…

Then the example so far to save the number into the parameter UserSession would be

web_create_html_param(“UserSession”, “input type=hidden name=userSession value=”, “>”);


In choosing a right boundary, make sure you choose enough static text to specify the end of the value. If the boundary you specify appears in the value you are trying to capture, then you will not capture the whole value.

Recap:-
That was a lot of looking through the recording and execution logs and checking of values. Lets just recap what we have done. We have identified a value that we think needs to be correlated. We then identified in the script where to place the statement that would ultimately capture and save the value into a parameter. We then placed the statement, and gave LoadRunner the text strings that appear on either side of the value we are looking for so that it can find it.

The flow of logic for this is, the correlation functions tells LoadRunner what to look for in the next set of replies from the server. LoadRunner makes a request of the server. The server replies. LoadRunner looks thorough the replies for the left and right boundaries. If it finds then, what is in-between is then saved to a parameter of the name specified.

Remember, the parameter can’t have a value till AFTER the next statement is executed. The correlation statement only tells LoadRunner what to look for. It doesn’t assign a value to the parameter. Assignment of a value to the parameter doesn’t happen till after LoadRunner makes a request of the server and looks in the reply. If you have in your script a case where a correlation statement is followed by a function that attempts to use the parameter, the statement is in the wrong place, and the script will fail.
This is always incorrect:-

web_create_html_param(…);
Web_submit (… {Parameter}…);

There needs to be in-between the two, the request of the server that causes it to reply with the value we are trying to capture.

Replacing the hard coded value in the script with the parameter.

Once we have created the parameter, the next step is to replace the hard coded occurrences with the parameter. Look through the script for the original value. Where you find it, delete out the value and replace it with the parameter. Note, only the value we want replaces is deleted. The characters around it remain.

i.e.

Change :                                                                    
             .....                                            .....userSession=75893.0884568651DQADHfApHDHfcDtccpfAttcf&username=test........
             .....                                                           
                                                                            
 To :                                                                       
             .....                                                          
             .....userSession={UserSession}&username=test........
             .....


At this point, you are ready to run the script to test if it works, or if it needs further correlation, or more work on this correlation.


Common errors when correlating.

When LoadRunner fails to find the boundaries for a web_create, it will print a warning message in the execution log like this:-

Warning: No match found for the requested parameter "Name". If the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size

Firstly, this is a warning not an error. There are times when you might want to use the web_create_html_param function for purposes other that correlation. These require the function to not cause an error, so this is a warning.

Secondly, the advice the warning message gives is good, but I recommend thinking about it first. Was the value you were trying to capture more than 256 characters long? In the above example it was only 20 characters long. Have a look at the recording log and see how long the original value is. Have a look at the second recording made earlier and see how long it was in that script. Turn on the extended log (Run-Time settings-> Log-> Extended log-> All data returned from server) and have a look at how long it is in the execution log. If at any time any of these values was close to being, say 200 characters, then yes, add a web_set_max_html_param_len statement to the start of the script to make the maximum longer than 256 characters. If all occurrences of the script were much shorter that the max parameter length then the problem is either the web_create_html_param is in the wrong place, or that the boundaries are incorrect. Go back and look at the boundaries that you have selected, look at the placement of the web_create_html_param function. Is it immediately before the statement that causes the server to reply with the data you are looking for?

The Parameter length is longer than the current maximum.
(The web_set_max_html_param_len function)

web_set_max_html_param_len ( “length” );

This statement tells LoadRunner to look for larger matches for the left and right parameter. When it finds the left boundary, it will look ahead the max parameter length for the right boundary. This setting is script wide, and takes effect from when it is executed. It only needs appear in the script once. Having LoadRunner look for longer matches uses up more memory, and CPU to search through the returned text from the server. For this reason, don’t set it too high, or you will be making your script less scalable. That is you will reduce the number of Vusers that can run it on a given machine. Try to have the maximum parameter length no more than 100 characters greater that what you are expecting.


Special cases for the boundaries:-

There are some special characters and cases when specifying the boundaries. Double quotes should be preceded by a \ so LoadRunner recognizes then as part of the string to look for. If your text includes any carriage returns, that are part of the http, and not just part of the wrap around in the recording log, these need to be specified as a \r\n character set. If the \ character is part of the text, it too needs to be preceded by a \ to indicate it is a literal.

Recording log                                                boundary parameters (left,               right)

Value=”57685”                                  “Value=\””                                           “\””

Value_”\item\”value’7875’                “Value_\”\\item\\\”value’                     “’”

Value=                                                            “Value=\r\n\””                                      “\””
“7898756”


Debug help

Sometimes you want to print out the value that was assigned to a parameter. To do this, use the lr_eval_string function, and the lr_output_message function. For example, to print the value of the parameter to the execution log.

lr_output_message(“ Value Captured = %s", lr_eval_string("{Name}"));

If you find that the value being substituted is too long, too short, or completely wrong, printing out the value will help identify the changes you need to make to the correlation function. If you have extra characters at the start of the value, you need to add them to the end of the left boundary, if you have extra characters at the end of the parameter value, you need to add them to the start of the right boundary. If you are getting the wrong value all together, do searches in the recording log for the left boundary, and make sure that you have a unique boundary, and that LoadRunner isn’t picking up an earlier occurrence. You can then use the web_create_html_param_ex function, or add to the boundaries to make them unique.


Other Correlation help resources.

The examples in the Function reference contain a lot of data and examples on how to use these function. I would recommend looking over them.

The Customer Support site has a video for download that goes over correlation. You can get it from

http://support.merc-int.com

After logging in, go to Downloads-> Brows. Enter LoadRunner in the product selection box, Mercury Interactive downloads radio button, and click on retrieve. Under training,
click on the LoadRunner Web Script Correlation Training link.

PERFORMANCE TESTING FOR CITRIX USING LOAD RUNNER


ABSTRACT

This paper details the recording, replaying tips for Citrix scripts using Load Runner and the Best practices that can be implemented while Performance testing the Citrix clients

INTRODUCTION

Citrix provides server and desktop virtualization, networking, software-as-a-services (SaaS), and cloud computing technologies, including Xen open source products

Citrix Terminology:

Citrix Server: Citrix Server work as a remote connection by users and allows multiple users that allows multiple applications at the  and allows multiple users that allows multiple applications at the same time.
Citrix Farm: Group of citrix servers with a load balancer which work as a traffic management in all servers using own effective algorithms.
Citrix XenApp: A thin client product that allows users to connect to their corporate applications. XenApp can either hostapplications on central servers or allow users to interact with them remotely or stream and deliver them to user devices for local execution.

Independent Computing Architecture

• A protocol used to provide desktop virtualization across different platforms but it is not bound to any platform.
• Data transfers from the server to the client generally involve a highlevel view of the display rather than a full image of the screen, dramatically saving bandwidth and reducing the dependency on latency.
• Utilizing this protocol, thin clients on a variety of end-user platforms may access applications on a centralized server that may not necessarily be supported on the end-user platform.

Recording and Validating the Citrix scripts

Citrix Recording Options:
•Using Server Credentials with published applications or by using ICA file.
•If you have an existing .ica file (provided by Citrix administrator/developer) with the entire relevant configuration information, select Use ICA file for connection parameters.

Citrix Script Validation:

Citrix provides three types of mechanism for Scriptvalidation:
1. ctrx_sync_on_text
A synchronization function that waits for a specified string to appear at the specified position before continuing.
2. ctrx_sync_on_window
It is a synchronization function that waits for a window to come into existence or become active.
3. ctrx_sync_on_bitmap
It is a synchronization function that waits for a specified bitmap to appear before continuing. The function can be manually recorded by clicking on the rectangle icon in VuGen's Citrix recording toolbar.





What are Common problems encountered while running the scripts Issue:

Error: Connect cannot be established - Last Error=70, Last
client error=1030
Error: Failed to create channel agent
Solution: The above mentioned error usually can be resolvedby
clearing the citrix client cache and registry, and re-running the citrix clearing the citrix client cache and registry, and re-running the citrix registry patch.
Steps for Clearing the citrix client cache and registry
• Close all the citrix based applications.
• Exitfrom "citrix program neighborhood agent“.
• Right click on the citrix program neighborhood agent icon and select "Exit"






• Run command regedit
• My Computer > HKEY_CURRENT_USER > Software>Citrix
• Delete Citrix Folder
• Delete Citrix Folder - right click Citrix folder and select Delete –Click Yes to 'Confirm key Delete' alert message.



• If c:\Documents and Settings\Administrator\Application Data has ICAClient and/or Citrix folders, delete these folders
•Reboot the machine.
•Run LRCtrxClient10Support_enableVC.reg citrix clientloadrunner
registry patch.

 

Best Practices:

1. Pre-Recording tips
2. Recording tips
3. Replay tips



Pre-Recording tips:

In the recording options we need to specify the user name, password, domain, connection type, citrix server name and published application. To find out which server to hit, follow these steps: To find out which server to hit, follow these steps:
• Open the application in Citrix - Right-click on Citrix Program Neighborhood Agent icon and chose the desired application.
• Get the server name - Right click on the Citrix Program Neighborhood Agent icon and click on Connection Center.

Recording tips:

• When recording a session, make sure to perform the complete  business process, starting with the connection and ending with the  cleanup. End your session at a point from where you could start the entire process from the beginning.
•Always make sure that your script is able to run for multiple  iterations.
• Record the connection process into the vuser_init section, and the  closing process in the vuser_end section. This will prevent you from  performing iterations on the connection process.
• Try to use keyboard as much as possible, use mouse only when there  is no alternative for keyboard shortcut.
•After every screen or step, apply text check. The function  ctrx_sync_on_text() can only be used if LoadRunner agent is installed  on the Citrix server. Here you cannot take image text from the screen.
•Avoid using ctrx_sync_on_bitmap() for synchronization. It is because  synchronization on bitmaps can lead to replay failure if different  machine is used.
•If you still need to use ctrx_sync_on_bitmap() thenfirst of all check  for the consistencies between the recorded and replay machines: for the consistencies between the recorded and replay machines: Window Size (resolution), Window Colors, System Font and the other  Default Options settings for the Citrix client. These settings affect the  hash value of bitmaps, and inconsistencies may cause replay to fail.

Replay Tips:

• For best results, do not disable think time in the Run-Time
settings. Think time is especially relevant before the
ctrx_sync_on_window and ctrx_sync_on_bitmap functions, which
require time to stabilize.
• After replay failure use different Login ID to login to the Citrix  Server. Since each login ID has some fixed specificsession time  span, logging in with the same ID before the session time has  expired would cause to take the user to same screenwhere it had  expired would cause to take the user to same screenwhere it had  left when the error occurred.
•Use the function ctrx_set_waiting_time before wait functions to set  the desired waiting time as shown in below snapshot. The  parameters connect and waiting timeout in runtime settings apply  only for connection event and synchronization functions,  respectively and not for wait functions.

Script Enhancements:

• To get proper response time for any particular transaction, keep  only the synchronization function inside it withoutthink time in  between.
• Use think time in between tabs to provide proper time for page  loading so that no events/hits are missed while replay.
• In some Citrix sessions, the active window name changes while you  • In some Citrix sessions, the active window name changes while you  are recording. If you try to replay the script as is, the Vuser uses the  original window name and the replay may fail then in that case we  can use wild card (*) in the same place.
E.g.: ctrx_sync_on_window ("User *", ACTIVATE, 187, 83, 427, 351,"snapshot1", CTRX_LAST);
Citrix agent – Friend or Foe?
•The LoadRunner Citrix agent was designed to make scripting  easier by recognizing objects. But sometimes when agent is  installed on the Citrix server, VuGen no longer works. Certain windows in the application would not even pop-up when doing a single mouse-click, and the only solution was to turn the Citrix  agent off.
•If you get to certain screens and everything seems to run at a  •If you get to certain screens and everything seems to run at a crawl, or it seems like your session is hanging, rename the LoadRunner Citrix agent on the server to turn it off . Then record a new script without it. If things are faster it may be the agent causing the problem. As always, ensure the agent isthe same version as the rest of your LR software.

Lost in Citrix Error:

• Following code is helpful when you are lost in a Citrix error where expected windows are not appearing where they are supposed to, or  they are not the right ones. Many times this will help you expose  just what the window and X/y coordinates are that are causing a problem.
•At the top of the script initialize the variables, and when you get to
 •At the top of the script initialize the variables, and when you get to a portion of the code where a problematic window has been stopping the script, place the ctrx_get_window_name  and ctrx_get_window_position right before it.charwindow_name[100];long xpos,ypos, width,height;ctrx_get_window_name(window_name);ctrx_get_window_position(window_name, &xpos, &ypos, &width, &height);
lr_output_message("Window = %s. x= %ld, y= %ld, width= %ld,
height = %ld", window_name, xpos, ypos, width,height);

• The ctrx_execute_on_window is a great way to handle unexpected screens that might appear anywhere in your script. If you know there  is a chance you will get hung on an unexpected screen, you can always code a separate function to use some known key sequence that can be used to get out safely (the example below uses the ENTER key). A function called enterkey_form_handler has been created and put into vuser_init section of the script in the VERY TOP before the vuser_init() is made:

• Intenterkey_form_handler(char win_title[]) {

 Intenterkey_form_handler(char win_title[]) {


ctrx_key("ENTER_KEY", 0, "snapshot130", CTRX_LAST);

return 0;}



                             
                                                THANK YOU


                         End of Document

SQL Server Counters for Monitoring SQL Server Performance

Do you have a list of SQL Server Counters you review when monitoring your SQL Server environment? Counters allow you a method to measure current performance, as well as performance over time. Identifying the metrics you like to use to measure SQL Server performance and collecting them over time gives you a quick and easy way to identify SQL Server problems, as well as graph your performance trend over time.
Below is my top 10 list of SQL Server counters in no particular order. For each counter I have described what it is, and in some cases I have described the ideal value of these counters. This list should give you a starting point for developing the metrics you want to use to measure database performance in your SQL Server environment.

1. SQLServer: Buffer Manager: Buffer cache hit ratio

The buffer cache hit ratio counter represents how often SQL Server is able to find data pages in its buffer cache when a query needs a data page. The higher this number the better, because it means SQL Server was able to get data for queries out of memory instead of reading from disk. You want this number to be as close to 100 as possible. Having this counter at 100 means that 100% of the time SQL Server has found the needed data pages in memory. A low buffer cache hit ratio could indicate a memory problem.

2. SQLServer: Buffer Manager: Page life expectancy

The page life expectancy counter measures how long pages stay in the buffer cache in seconds. The longer a page stays in memory, the more likely SQL Server will not need to read from disk to resolve a query. You should watch this counter over time to determine a baseline for what is normal in your database environment. Some say anything below 300 (or 5 minutes) means you might need additional memory.

3. SQLServer: SQL Statistics: Batch Requests/Sec

Batch Requests/Sec measures the number of batches SQL Server is receiving per second. This counter is a good indicator of how much activity is being processed by your SQL Server box. The higher the number, the more queries are being executed on your box. Like many counters, there is no single number that can be used universally to indicate your machine is too busy. Today’s machines are getting more and more powerful all the time and therefore can process more batch requests per second. You should review this counter over time to determine a baseline number for your environment.

4. SQLServer: SQL Statistics: SQL Compilations/Sec

The SQL Compilations/Sec measure the number of times SQL Server compiles an execution plan per second. Compiling an execution plan is a resource-intensive operation. Compilations/Sec should be compared with the number of Batch Requests/Sec to get an indication of whether or not complications might be hurting your performance. To do that, divide the number of batch requests by the number of compiles per second to give you a ratio of the number of batches executed per compile. Ideally you want to have one compile per every 10 batch requests.

5. SQLServer: SQL Statistics: SQL Re-Compilations/Sec

When the execution plan is invalidated due to some significant event, SQL Server will re-compile it. The Re-compilations/Sec counter measures the number of time a re-compile event was triggered per second. Re-compiles, like compiles, are expensive operations so you want to minimize the number of re-compiles. Ideally you want to keep this counter less than 10% of the number of Compilations/Sec.

6. SQLServer: General Statistics: User Connections

The user connections counter identifies the number of different users that are connected to SQL Server at the time the sample was taken. You need to watch this counter over time to understand your baseline user connection numbers. Once you have some idea of your high and low water marks during normal usage of your system, you can then look for times when this counter exceeds the high and low marks. If the value of this counter goes down and the load on the system is the same, then you might have a bottleneck that is not allowing your server to handle the normal load. Keep in mind though that this counter value might go down just because less people are using your SQL Server instance.

7. SQLServer: Locks: Lock Waits / Sec: _Total

In order for SQL Server to manage concurrent users on the system, SQL Server needs to lock resources from time to time. The lock waits per second counter tracks the number of times per second that SQL Server is not able to retain a lock right away for a resource. Ideally you don't want any request to wait for a lock. Therefore you want to keep this counter at zero, or close to zero at all times.

8. SQLServer: Access Methods: Page Splits / Sec

This counter measures the number of times SQL Server had to split a page when updating or inserting data per second. Page splits are expensive, and cause your table to perform more poorly due to fragmentation. Therefore, the fewer page splits you have the better your system will perform. Ideally this counter should be less than 20% of the batch requests per second.

9. SQLServer: General Statistic: Processes Block

The processes blocked counter identifies the number of blocked processes. When one process is blocking another process, the blocked process cannot move forward with its execution plan until the resource that is causing it to wait is freed up. Ideally you don't want to see any blocked processes. When processes are being blocked you should investigate.

10. SQLServer: Buffer Manager: Checkpoint Pages / Sec

The checkpoint pages per second counter measures the number of pages written to disk by a checkpoint operation. You should watch this counter over time to establish a baseline for your systems. Once a baseline value has been established you can watch this value to see if it is climbing. If this counter is climbing, it might mean you are running into memory pressures that are causing dirty pages to be flushed to disk more frequently than normal.