CS代写 Lab – Load Testing Dell DVD Store (DS2)

Lab – Load Testing Dell DVD Store (DS2)
1. Overview
In this lab, you will load test the Dell DVD store application. By completing this lab, you will learn how to:
 Deploy the system under test

Copyright By PowCoder代写 加微信 powcoder

 Configure the performance monitoring tools
 Configure the load driver
 Execute the load test
 Terminate the load test and collect the data
 Analyze the results of this load test
2. System Deployment
In general, the system deployment process varies. Here, we just use Dell DVD store as an illustrative example. (http://linux.dell.com/dvdstore/) The system consists of the following three components:
 A web front-end written in JSP
 A MySQL database, and
 A load driver
Note that the following setup instructions are for a Window machine.
2.1 Download All the Components
DS2: Download the ds21_mysql.tar.gz and ds21.tar.gz from http://linux.dell.com/dvdstore/ to a selected location in your computer. Unzip the two gzip files. When prompted for merging file contents, click “OK”. You should see a folder called “ds2” in your local drive.
MySQL: Download the latest version of MySQL (e.g., MySQL Community version 5.6.20) and install it.
 Pick the full installation option
 Set the root password as “password” or whatever the string that you can remember
 Uncheck “Start MySQL server at system startup”
Tomcat: Download the latest version of Tomcat v7 (e.g., version 7.0.55) and install it.
 Pick the full installation option
 Check the Tomcat service startup from “Automatic” to “Manual”

 To verify the Tomcat installation: type “localhost:8080” in your browser, you should see a welcome page like this
2.2 Load Data into the MySQL Database
Currently there is no DS2 database in MySQL. We need to first create the database and tables for DS2. Then we will load the initial test data.
1. Add MySQL to your execution path
 Computer -> Advanced System Settings -> Environment Variables -> Edit the “PATH”
variable under User variables
 Append the MySQL bin string to the end of the PATH
2. Create DS2 database, tables and load the initial test data
 Open a command prompt and verify if MySQL is already in the execution path by typing
o mysql –help
 Go to this directory: ds2\mysqlds2 and do the following command:
o copy mysqlds2_create_all.sh mysqlds2_create_all.bat  Edit this file: ds2\mysqlds2\mysqlds2_create_all.bat
o Replace all “/” with “\”
o Replace the comment strings “#” with “::”
o Replace “ web” with “ root”
o Replace “password=web” with “password=password” or whatever the root password
you have set with
 Edit this file: ds2\mysqlds2\build\ mysqlds2_create_db.sql
o Replace “TYPE= InnoDB;” as “ENGINE= InnoDB;”
o Replace “TYPE=MyISAM;” as “ENGINE=MyISAM;”  Go to ds2\mysqlds2 and run mysqlds2_create_all.bat
o Don’t worry about the warning message “Warning: Using a password on the command line interface can be insecure.”

 Open the MySQL Workbench and type in the root password, you should be able to see the
ds2 database and tables created
2.3 Deploy the DS2 Web JSP files
1. Copy the directory ds2\mysqlds2\web\jsp to the Tomcat web deployment directory (Tomcat 7.0\webapps\ROOT\)
2. Rename jsp folder as “ds2”. Verify the setup by typing the link http://localhost:8080/ds2/index.html in your browser
3. Edit all three jsp files in the ds2 folder
a. Replace “user=web&password=web” as “user=root&password=password”
4. Configure the JDBC driver (MySQL J Connector) for Tomcat
a. Check if there is a MySQL connector in the MySQL installation directory. If not,
download the latest one from the web
b. Copy “MySQL\Connector J 5.1.31\ mysql-connector-java-5.1.31-bin.jar” to “Tomcat
7.0\webapps\ROOT\WEB-INF\lib”

c. Add this jar file (Tomcat 7.0\webapps\ROOT\WEB-INF\lib\mysql-connector-java-
5.1.31-bin.jar) to the
Tomcat classpath:
d. Restart (Stop and then
start) the Tomcat service
5. Verify the JSP setup: go to http://localhost:8080/ds2/index.html in your browser, and login as “user1” and “password” for the user ID and password, respectively. You should see the following DS2 welcome page in your browser:

Note that Tomcat is highly configurable. For example, if you don’t want to type the default port number (8080) every time you type the URL, you can change the HTTP port configuration information at Tomcat 7.0\conf\server.xml to port 80 instead.
2.4 Increase the # of connections for MySQL
Edit this file: C:\ProgramData\MySQL\MySQL Server 5.6\mysql.ini file, and change the max_connections value to be 1000. Restart the MySQL service.
2.5 Increase the # of ports for Windows
Edit the registry keys by going to Run -> Regedit. Then follow the path specified as follows: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, and Right click -> New -> DWORD Value -> 65534 (decimal). (For details, check this page: https://msdn.microsoft.com/en-us/library/aa560610%28v=bts.20%29.aspx)
3. System Monitoring Tools
There are many system monitoring solutions available. Some of the paid applications (e.g., CA Wiley) are highly automated. Here, I use the readily available software.
3.1 Metrics Monitoring & Recording for the General Processes
We will use PerfMon to monitor and record the performance metrics for our processes (e.g., MySQL).
 Launch the PerfMon by typing “perfmon” in the Run process.
 Right click the data display area -> Add Counters -> Click the “Process”. You should see a
list of currently active processes under the area of “Instances of selected object”. You can include all these counters for a selected process (by default). Or you can pick a subset of these counters by picking the process first, then clicking each counter and the “add” button. Let’s say for now: pick the basic CPU/Disk/Memory counters for the MySQL process (mysqld):
 % Privileged Time
 % Processor Time
 % User Time
 % IO Data Bytes/Sec
 % IO Read Bytes/Sec
 % IO Write Bytes/Sec
 Private Bytes
 Virtual Bytes
 Working Set

Click “OK”, once you are done. These metrics can now be monitored inside the PerfMon window. For each counter, you can configure a number of display options (e.g., sampling interval, colour, line type, display scale, etc.).
The above steps show you how to monitor the system performance. If you want to perform off- line analysis, you need to record these performance counters:
 Right click “Performance Monitor” -> New -> Data Collection Set
 Name the collection set as “DS2_Data” and pick a directory to store these data and then keep
all the other values as default and click “Finish”. Then you should see the DS2_Data shown below:
 Double click the “System Monitor Log” to configure about
 the sampling frequency (e.g., every 5 seconds) and output format (e.g., tsv format)
 the output file (DS2_) and file name format (mmddhhmm)
 To start the DS2_data counter collection, you can either click the top arrow button to start. Or you can open up a command prompt (with Admin rights) and type

 logman start ds2_data
 To stop the counter collection, you can either click the square button to stop. Or you can type
in the command prompt (with Admin rights) and type
 logman stop ds2_data
 In your data collection directory, you should see a file called “DS2_xxxxxxxx.tsv”, which
records the performance data for the mysqld process.
 If you want to start collecting the counters defined in the DS2_data collection again, you can
simply repeat the start/stop processes above. A new tsv file should be generated.
Aside 1: Some other processes (e.g., Microsoft SQL Server) impose additional metrics (e.g., # of transactions, # of connections) inside PerfMon. You can apply the similar process to create a data collect set and record their behavior.
Aside 2: If you want to record the performance behavior in Linux, you can For Linux platform, look into the pidstat and iostat command inside the sysstat package. Make sure when you run the pidstat with the “- l” option to show the process command name and their arguments. This could be useful if you are running multiple processes with the same name (e.g., different Java applications).
3.2 Metrics Monitoring for Tomcat and other Java-based Applications
The above processes work great for most of the processes, but not for Java applications. Java applications run on top of JVMs, which do their own management in terms of memory, threads and other stuff. Hence, we usually collect the following two types of additional data for Java applications.
1. Java virtual machine metrics via the JMX monitoring interface (http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html). Note that the JMX remote monitoring port (9010 here) can be any currently unused port:
2. Garbage collection logs
3. Both of the above options are Java command line options. It can be configured either by editing the Tomcat Registry or via the GUI console. Make sure there are no spaces at the end of each
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-verbose:gc
-XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:logs/gc.log

line when editing the Java options. Restart the Tomcat Service after the changes.
4. To verify the setup:
o Check if the garbage collection log files exists: Tomcat 7.0\logs\gc.log o Open JConsole (make sure you have JDK 7 installed already)
 Open JConsole.exe from Java\jdk1.7.0_67\bin\
 Say remote process and enter “localhost:9010”
o You should see the JConsole information as below. Note that the sampling period for
each of these metrics can be adjusted by right clicking the graphs. In addition, the data from each of these metrics can be saved as a csv file.

Additional Exercise: Write a Java program which can automatically collect the JMX statistics any of the Java applications by specifying the sampling period and the JMX monitoring port as the command line option.
3.3 Tomcat Logging Options
This section describes the logging options for Tomcat.
 You can change the Tomcat logging options using the Configuration GUI as shown below:
 In addition, if you add the debug statements in the JSP pages, it will appear in the log files as well. For example:
 If you enter the following in the dslogin.jsp, it will appear in the tomcat7- stdout.xxxx-xx-xx.txt file.
i. System.out.println(“in stdout customer id is ” + username + “\n”);
 If you change System.out to System.err, it will appear in the tomcat7- stderr.xxxx-xx- xx.txt file.
i. System.err.println(“in stdout customer id is ” + username + “\n”);
 Apache Access logs by default do not track the response time. To enable response time logging, you add “%D” to the server.xml file and restart the Tomcat process.

Note that each line of access log records the URL of the requests, the HTTP status code, # of bytes sent, the response time (in milliseconds). For details, you can check this page: https://tomcat.apache.org/tomcat-7.0- doc/api/org/apache/catalina/valves/AccessLogValve.html
4. DS2 Load Driver
You can either use the included web load driver or JMeter. We will cover the DS2 load driver in this section and JMeter in the next section.
DS2 comes with its own load driver (written in C#). The file ds2\drivers\ds2driver_doc.txt contains the detailed instructions on how to run the load driver. For now, let’s just use the following simple options and run a load test for 2 minutes:
 Create a configuration file called ds2_driver_config.txt with the following contents:
target=localhost:8080 db_size=S run_time=5 virt_dir=ds2 page_type=jsp think_time=1
 To run the load driver, type the following in the command prompt:
 ds2webdriver.exe –config_file=ds2_driver_config.txt
(Note that many errors in the console are related to the performance stats about the load driver. They can be safely ignored.)
 Once the test is completed, make sure you do the following:
 Stop the performance counter collections
 Move the performance counter data to a safe location for further analysis
 Move the apache logs to a safe location for future analysis
 Analyze the counters and logs
Additional Exercise 1: Are there any bugs in the web load driver? Note that the load driver can be modified or enhanced if needed. For details on how to edit and recompile the driver code, you can consult ds2\drivers\ds2_drivers_readme.txt.
5. JMeter Load Driver
JMeter is a free open source load driver from Apache foundation. Here, we will configure the load test by applying the “record-and-replay” technique.
1. Locate the JMeter application in downloaded\apache-jmeter-2.11.zip. Unzip the file to a folder of your choice.
2. Launch JMeter by double clicking the bat file from apache-jmeter-2.11\bin\jmeter.bat

3. Define the number of test scenarios. For this lab, let’s say there are two scenarios: one for “Returning users” and one for “ ”. Hence, we need to create two thread groups for the two test scenarios, respectively.
4. Let’s create the first thread group “Returning Users”
 Right click Test Plan -> Add -> Threads (Users) -> Thread Group -> Name this thread
group as “Returning Users”
 Right click Returning Users -> Add -> Configure Element -> HTTP Request Defaults
 Enter “localhost” as the server name, port number as “8080”
5. Add the Recording Controller, which is a placeholder for the proxy server to record samples
 Right click Returning User thread group -> Add -> Logic Controller -> Recording
Controller
6. Add a proxy server under the WorkBench. WorkBench is a temporarily place to store the test
 Right click WorkBench -> Add -> Non-Test Elements -> HTTP (s) Test Script Recorder  Change the port number to 9090 and keep everything else as default
 Right click HTTP (s) Test Script Recorder -> Add -> Listener -> View Results Tree, so
that we can verify the recorded data
7. Change browser proxy settings to print to localhost and port 9090.
 For Chrome: Settings -> Show Advanced Settings -> Proxy -> LAN Settings

8. Now we are ready to record our test scenario for “Returning Users”
 Click the “Start” button on the bottom of the “HTTP(s) Test Script Recorder” page.
 Click ok, when it prompts for the Apache JMeter certificate.
 Go to your browser and complete the following action sequences:
 Enter “localhost:8080/ds2” and login with “user1/password”
 Click “Startshopping”
 Click “Category” and keep “Action”, and click search
 Add to the shopping cart, then purchase, you should see purchase successful
screen like the one shown below:
9. Click “Stop” button at the bottom of the “HTTP(s) Test Script Recorder”
10. Add HTTP Cookie Manager to manage cookies for each session
 Right click Returning Users -> Configuration Elements -> HTTP Cookie Manager
 Check “Clear cookies each iteration?”

11. Repeat step 1 and step 2 to create and configure another thread group called “ ” 12. Move the group above the Returning User group as shown below.
13. Record the test scenario for “ ”
 Click the “Start” button on the bottom of the “HTTP(s) Test Script Recorder” page.
 Click ok, when it prompts for the Apache JMeter certificate.
 Go to your browser and complete the following action sequences
 Enter “localhost:8080/ds1” and enter something like the following. The username and the password need to be “newuser1” and “password” to make the rest of the lab working. Also make sure the “Age” field has a numeric number, otherwise the system will throw an exception.

 Once, complete, then click “start shopping”
 Select category as “Children” and buy the selected movie
14. Since we need unique new users for each new user registrtion, the best way is to ask JMeter to
read the list of new users from a file:
 Right click -> Add -> Config Element -> CSV Data Set Config
 Inside the CSV Data Set Config, name it as “NewUserList” and enter the proper path for
the csv file and variable names as shown below (username,password). Not that you can locate the file newuser.csv in the provided lab zip file.
 Click the newcustomer page -> under parameters, change the values of “username”, and “password” to the variables ${username} and ${password} (see the screenshot below):
 Notice that if the new customer registration is completed successfully, once you click “Start shopping”, you will be redirected to the browse page with the newly generated customer ID. Hence, to automated this process in JMeter, you need to capture the newly generated customer ID. If you check the response from the new customer request, the customer ID is returned as “hidden variables”. You can find the information from “View Results Tree -> /ds2/newcustomer.jsp -> Response Data” (see screenshot below):

We need to have a way to automatically extract the customer ID from the response to be used in the rest of the purchasing session. To do this, right click, the dsnewcustomer page in the “ ” thread group: add -> post processors -> regular expression extractor
Enter the information as shown above. Once complete, make sure you replace the customer ID with this variable ${customerid} for the rest of the recorded pages. See the screenshot below for an example:

15. Add timers to both thread groups
 Right click “/ds2/dspurchase.jsp” from the Returning Users -> Timer -> Constant Timer ->
“1000 msec” as the new thread delay value
 Similarly do Constant Timer and “1000 msec” delay for the “ ” group. Place
the timer after “/ds2/dspurchase.jsp”
16. Configure the number of threads and iterations/test duration
 For -> Set “Number of Threads” to be 2 and ramp up period to be 5 seconds
 For Returning Users -> Set “Number of Threads” to be 1 and Loop count as “20”
17. Store the test results
 Right click -> Add -> Listener -> View Results in a Tree
 Right click Returning Users -> Add -> Listener -> View Results in a Tree
18. Save the test plan (File -> Save) to a location of your choice
6. Test Execution and Monitoring
1. Remove the Browser proxy setup
2. In JMeter: click Run -> Start

3. You can monitor the health of the test by checking each page under the View Results in a Tree tab under each thread group. For better viewing of html page, select “HTML” on the bottom left corner.
Another way to verify this test is to login as individual users and check their orders. For each new user, there should be exactly 1 order. For the j2ee (returning user), there should be 21 orders (including the initially recorded order).
4. Once the test is completed, make sure you do the following:
 Stop the performance counter collections
 Move the performance counter data to a safe location for further analysis
 Move the apache logs to a safe location for future analysis
5. Analyze the counters and logs
7. Test Analysis
In this section, we will analyze the results of this very simple test.
1. Parse the Apache access logs to see how many URL requests are sent. Are all requests processed successfully? Generate a scatter plot for the response time metric.
2. Generate line plots for the PerfMon data.
3. Generate line plots for the JConsole data.
8. Start a different test or repeat this test
You need to do the following cleanup tasks before performing another load test:
 Remove the existing logs and counter data
 Shutdown all the services (MySQL + Tomcat)
 Restore the database by running the following command:
o Go to ds2\mysqlds2
o Run mysqlds2_create_all.bat
9. Take home exercises
 Basic Deliverables
 Run a load test for about 5 minutes or 500 requests with the performance counter data and logs collected.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com