You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VaadinScalabilityTestingWithAmazonWebServices.asciidoc 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. ---
  2. title: Vaadin Scalability Testing With Amazon Web Services
  3. order: 52
  4. layout: page
  5. ---
  6. [[vaadin-scalability-testing-with-amazon-web-services]]
  7. = Vaadin scalability testing with Amazon Web Services
  8. This article explains how you can test the scalability of your
  9. application in the Amazon Web Services (AWS) cloud. The AWS services
  10. used in this article include http://aws.amazon.com/ec2/[Amazon Elastic
  11. Compute Cloud] (EC2) and http://aws.amazon.com/rds/[Amazon Relational
  12. Database Service] (RDS). The use of
  13. http://aws.amazon.com/elasticloadbalancing/[Amazon Elastic Load
  14. Balancing] (ELB) is also briefly discussed. The application under
  15. testing is called QuickTickets, a fictional Vaadin web application that
  16. sells movie tickets to theaters all over the world. See also the
  17. https://vaadin.com/blog/vaadin-scalability-study-quicktickets[blog
  18. post about the experiment and the results].
  19. To fully understand this article and follow through the steps, you
  20. should have some basic knowledge of Amazon Web Services (AWS),
  21. http://jakarta.apache.org/jmeter/[Apache JMeter], MySQL and Linux shell
  22. usage. You will also need to know how to checkout the
  23. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/[QuickTickets
  24. project] from SVN and run http://ant.apache.org/[Ant] targets to
  25. generate test database and to package the application as a WAR file.
  26. Please notice, that using the AWS services discussed here will incur
  27. some expenses.
  28. [[setting-up-the-amazon-rds-database]]
  29. 1. Setting up the Amazon RDS database
  30. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  31. * Login to http://aws.amazon.com/console/[AWS Management Console] and
  32. select the Amazon RDS tab.
  33. * Click the Launch DB Instance button.
  34. * Select the following properties for the DB instance:
  35. ** DB Instance Class: db1.m1.large
  36. ** Multi-AZ Deployment: No
  37. ** Allocated Storage: 5 GB
  38. ** DB Instance Idenfitier: `quicktickets`
  39. ** Master User Name: `quicktickets`
  40. ** Master User Password: `<your-password>`
  41. * Additional configuration:
  42. ** Database Name: `quicktickets`
  43. * Management options:
  44. ** Backup Retention Period: 0 (disable backups)
  45. * After the DB instance is started up, connect to the database with the
  46. MySQL client.
  47. ** If this is the first time you are using Amazon RDS, you need to setup
  48. the DB Security Groups.
  49. ** More information about http://aws.amazon.com/rds/faqs/#31[network
  50. access to you DB instances].
  51. * Once you have connected to the DB, run the following
  52. command: `alter database quicktickets charset=utf8;`
  53. * Note that the following steps might be a bit faster to do in an EC2
  54. instance in the same zone as the RDS database. But you can of course do
  55. these in your local machine as well.
  56. * Take a checkout of the QuickTickets application project from the
  57. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/application/QuickTickets/[SVN
  58. repository].
  59. * Create the database schema by running the
  60. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/application/QuickTickets/db/createSchema.sql[QuickTickets/db/createSchema.sql]
  61. file to the quicktickets
  62. database.`mysql -uquicktickets -p<your-password> -h<db-instance-endpoint>.rds.amazonaws.com < QuickTickets/db/createSchema.sql`
  63. * Create a huge test data by running Ant target
  64. `create-huge-database-script` of the
  65. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/application/QuickTickets/build.xml[QuickTickets/build.xml]
  66. script.`cd QuickTicketsant create-huge-database-script`
  67. * This target will generate a huge SQL file (500MB) into a temporary
  68. directory containing loads of test data. The location of the file is
  69. printed to the console by the Ant target.
  70. * Run the resulting `quickticketsdata.sql` file to the quicktickets
  71. database (this will take quite a while, well over an
  72. hour). `mysql -uquicktickets -p<your-password> -h<db-instance-endpoint>.rds.amazonaws.com < /tmp/quickticketsdata.sql`
  73. [[setting-up-ec2-instances-for-quicktickets]]
  74. 2. Setting up EC2 instance(s) for QuickTickets
  75. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  76. * Login to http://aws.amazon.com/console/[AWS Management Console] and
  77. select the Amazon EC2 tab.
  78. * Click the Launch Instance button.
  79. * Select Community AMIs tab and search an AMI with following id:
  80. `ami-fb16f992`
  81. * Launch a large instance of the AMI. Consult the
  82. http://aws.amazon.com/documentation/ec2/[Amazon EC2 documentation] for
  83. more details on how to launch a new instance.
  84. * Login to the started instance as root via SSH.
  85. * Copy and execute the
  86. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/installationscripts/webserver-memcached.sh[webserver-memcached.sh]
  87. installation script as the root user. This script will setup
  88. http://memcached.org/[Memcached] and http://tomcat.apache.org/[Apache
  89. Tomcat].
  90. * Repeat the above procedure for all the instances you want to setup.
  91. [[deploying-the-quicktickets-application]]
  92. 3. Deploying the QuickTickets application
  93. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  94. * Take a checkout of the QuickTickets application project (if you
  95. haven't already) from:
  96. ** http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/application/QuickTickets/
  97. * Add the *Private DNS* of all the instances you have setup to the list
  98. of Memcached servers in the `WebContent/WEB-INF/servers.xml` file with
  99. the default Memcached port 11211. For
  100. example: `<!-- Memcached servers --&gt;<value>ip-11-111-11-111.ec2.internal:11211</value><value>ip-22-222-22-222.ec2.internal:11211</value>...`
  101. * Create a file called `build.properties` to the root directory of the
  102. project (right next to the `QuickTickets/build.xml`). Set the
  103. `productionMode` property to `true` and add your Amazon RDS database
  104. configuration details to the file. For example:
  105. ....
  106. # Debug or production mode?
  107. productionMode=true
  108. # Database configuration
  109. database.url=jdbc:mysql:<db-instance-endpoint>.rds.amazonaws.com:3306/quicktickets?characterEncoding=utf8&useCompression=true
  110. database.username=quicktickets
  111. database.password=<your-password-here>
  112. database.driverClassName=com.mysql.jdbc.Driver
  113. ....
  114. * Run the `package-war` target of the `build.xml` to compile and package
  115. the WAR file (resulting in the `build/ROOT.war` file).`ant package-war`
  116. * Deploy the WAR file into all EC2 instances you just created by copying
  117. the `ROOT.war` into `/opt/apache-tomcat/webapps` directory.
  118. * Now you should be able to access the application through your web
  119. browser by opening the following
  120. URL: `http://<instance-public-dns>.amazonaws.com:8080/app`
  121. * If you did setup more than one instance, you could create an Amazon
  122. ELB load balancer and attach all instances to that load balancer.
  123. However, this makes the JMeter testing close to impossible as the ELB
  124. doesn't scale to sudden increases in traffic fast enough and starts
  125. dropping connections.
  126. ** More information:
  127. https://forums.aws.amazon.com/thread.jspa?messageID=130622&tstart=0
  128. ** More information:
  129. https://wiki.apache.org/jmeter/JMeterAndAmazon
  130. * If you still want to try using ELB, you should add
  131. `-Dsun.net.inetaddr.ttl=0` to the JMeter JVM args and use the following
  132. settings with the ELB:
  133. ** Port Configuration: 80 forwarding to 8080
  134. ** Enable Application Generated Cookie Stickiness for cookie name:
  135. `jsessionid`
  136. ** Set the Health Check port to `8080`
  137. ** Ping Path: `/VAADIN/ticket.html`
  138. [[setting-up-ec2-instances-for-jmeter]]
  139. 4. Setting up EC2 instance(s) for JMeter
  140. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  141. * Launch and login to a new EC2 large instance (using the AMI
  142. `ami-fb16f992`). See the first 5 steps of the second chapter.
  143. * Copy and execute the
  144. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/installationscripts/jmeter-instance.sh[jmeter-instance.sh]
  145. installation script as the root user.
  146. * Download the
  147. http://dev.vaadin.com/svn/incubator/QuickTickets/trunk/installationscripts/jmeter-test-script.jmx[JMeter
  148. script].
  149. ** The script contains prerecorded ticket purchase sequence that lasts
  150. about 2.5 minutes.
  151. * Open the script in JMeter and make sure you configure the following
  152. settings to suit your test:
  153. ** HTTP Request Defaults (set the server name)
  154. ** Thread Group (thread count, ramp-up, loop count)
  155. ** Summary report (result file name)
  156. * Upload the test script to the JMeter instance(s).
  157. * When logged in as root to the JMeter server you can start the test
  158. from command line with the following
  159. command: `~/jakarta-jmeter-2.4/bin/jmeter.sh -n -t ~/jmeter-test-script.jmx`
  160. * After the run is complete you'll have `jmeter-results.jtl` file (or
  161. the filename you used for the report) which you can open in JMeter for
  162. analyzing the results.
  163. [[results]]
  164. 5. Results
  165. ^^^^^^^^^^
  166. Jump directly to the results:
  167. https://vaadin.com/blog/vaadin-scalability-study-quicktickets[blog
  168. post about the experiment and the results].