Universidad Carlos Iii De Madrid Escuela Politécnica Superior
Total Page:16
File Type:pdf, Size:1020Kb
UNIVERSIDAD CARLOS III DE MADRID ESCUELA POLITÉCNICA SUPERIOR INGENIERÍA DE TELECOMUNICACIÓN Delivering an Olympic Games Autor: Agustín Treceño Orgaz Tutor: Mario Muñoz Organero This page intentionally left blank Delivering an Olympic Games Agustin Treceno December 9, 2013 Dedicated to my parents. Abstract The technology involved in the distribution of the results during an Olympic Games is extremely complex. More than 900 servers, 1,000 network devices, 9,500 computers and 3,500 technologists are necessary to make it happen. Would it be possible to implement a solution with less resources using cutting edge tech- nology? The following study answers this question by designing two scalable and high performance web-based applications to manage tournaments offering a REST interface to stakeholders. The first solution architecture is based on Java using frameworks such as Spring and Hibernate. The second solution architec- ture uses JavaScript with frameworks such as NodeJS, AngularJS, Mongoose and Express. Contents 1 Introduction 1 1.1 Motivation .............................. 1 1.2 Objectives ............................... 1 1.3 About this document ......................... 2 1.3.1 Source code .......................... 2 1.3.2 Roadmap ........................... 2 2 Behind the Olympics 3 2.1 Architecture .............................. 3 2.2 The Olympic Data Feed ....................... 5 3 Spring Solution Architecture 9 3.1 Introduction to Spring ........................ 9 3.1.1 Features ............................ 9 3.1.1.1 Based on Plain Old Java Object (POJO) .... 10 3.1.1.2 Loose coupling through Dependency Injection (DI) and interface orientation ........... 10 3.1.1.3 Separation of concerns through Aspect-Oriented Programming (AOP) ............... 10 3.1.1.4 Boilerplate reduction through templates ..... 11 i 3.1.2 Spring Modules ........................ 11 3.1.3 The IoC Container ...................... 12 3.1.4 Aspect-Oriented Programming (AOP) ........... 14 3.1.5 Alternatives to Spring .................... 15 3.2 Design and Implementation ..................... 17 3.2.1 Java Scaffolding ....................... 17 3.2.2 Persistence Layer ....................... 20 3.2.2.1 The Model ..................... 20 3.2.2.2 Configuring JPA .................. 20 3.2.2.3 Creating Entities .................. 25 3.2.2.4 JavaBean Support ................. 28 3.2.2.5 Bean Validation .................. 30 3.2.2.6 Using Reflection .................. 30 3.2.2.7 Comparing Entities ................ 30 3.2.2.8 Defining Entity Relationships ........... 31 3.2.2.9 Active Record Pattern ............... 33 3.2.2.10 Repository Pattern ................ 37 3.2.3 Service Layer ......................... 39 3.2.3.1 Configuring a Service Layer ............ 39 3.2.3.2 Transaction Management ............. 41 3.2.4 Web Layer .......................... 44 3.2.4.1 The Basics ..................... 44 3.2.4.2 Setting up Spring MVC .............. 44 3.2.4.3 Adding Security .................. 56 3.3 Cloud Deployment .......................... 59 3.3.1 Pivotal CF with ClearDB .................. 60 3.3.2 Heroku with Amazon RDS ................. 65 3.4 Testing ................................. 75 3.4.1 Logic Unit Tests ....................... 76 3.4.2 Integration Unit Tests .................... 78 3.4.3 Front-end Unit Tests ..................... 82 ii 3.4.4 Integration Tests ....................... 92 3.4.5 Non-functional Tests ..................... 94 3.4.5.1 Load testing with Siege .............. 94 3.4.5.2 Stress Testing with Siege ............. 110 4 NodeJS Solution Architecture 117 4.1 Introduction to NodeJS ....................... 117 4.2 Design and Implementation ..................... 118 4.2.1 JavaScript Scaffolding .................... 118 4.2.2 Responsive Web Design ................... 121 4.2.2.1 Zurb Foundation .................. 122 4.2.2.2 Twitter Bootstrap ................. 126 4.2.3 Build Process ......................... 129 4.3 Cloud Deployment .......................... 132 4.4 Testing ................................. 134 4.4.1 Unit Tests ........................... 134 4.4.2 End-to-End Tests ....................... 139 4.4.3 Non-functional Tests ..................... 144 4.4.3.1 Load testing with Siege .............. 144 4.4.3.2 Stress Testing with Siege ............. 153 5 Conclusions and Future Work 160 5.1 Conclusions .............................. 160 5.2 Future Work ............................. 161 5.2.1 Real-time Results ....................... 162 5.2.2 Offline Capabilities ...................... 162 5.2.3 Speeding-up Results ..................... 162 A Working with Git 163 A.1 The Basics .............................. 164 A.2 Initialising a Repository ....................... 165 A.3 Adding a Remote Repository .................... 168 A.4 Working within a Team ....................... 169 iii B Installing MySQL 177 B.1 Installation on Mac OS X ...................... 177 B.2 Post-installation set-up ........................ 180 C Installing Apache Benchmark 183 D Quote 186 References 192 iv List of Figures 2.1 Architecture of the results information system ........... 4 3.1 DI trends from July 2010 to July 2013 (source: Google Trends) . 16 3.2 EER Model of a sporting event (Crow’s foot notation) ...... 21 3.3 Cloud Foundry plugin for STS ................... 61 3.4 Pivotal CF web interface ....................... 64 3.5 Diaulos deployed to Pivotal CF ................... 66 3.6 Heroku Dashboard - Diaulos ..................... 67 3.7 AWS Management Console ..................... 70 3.8 Selenium IDE ............................. 85 3.9 Memory usage with one web dyno ................. 93 3.10 Server Response Time - Load Testing - Diaulos .......... 102 3.11 Server Throughput - Load Testing - Diaulos ............ 104 3.12 Apdex Score - Load Testing - Diaulos ............... 104 3.13 Top Web Transactions - Load Testing - Diaulos .......... 106 3.14 List of Web Transactions - Load Testing - Diaulos ........ 106 3.15 Database Response Time - Load Testing - Diaulos ........ 107 3.16 Database Throughput - Load Testing - Diaulos .......... 107 3.17 Top DB Operations - Load Testing - Diaulos ........... 108 v 3.18 Number of instances and Load - Load Testing - Diaulos ..... 108 3.19 CPU Usage - Load Testing - Diaulos ................ 109 3.20 Memory Usage - Load Testing - Diaulos .............. 109 3.21 Garbage Collector Usage - Load Testing - Diaulos ......... 109 3.22 Server Response Time - Stress Testing - Diaulos .......... 112 3.23 Server Throughput - Stress Testing - Diaulos ........... 112 3.24 Apdex Score - Stress Testing - Diaulos ............... 112 3.25 Top Web Transactions - Stress Testing - Diaulos ......... 113 3.26 Database Response Time - Stress Testing - Diaulos ........ 113 3.27 Database Throughput - Stress Testing - Diaulos .......... 114 3.28 Top DB Operations - Stress Testing - Diaulos ........... 114 3.29 Number of instances and Load - Stress Testing - Diaulos ..... 115 3.30 CPU Usage - Stress Testing - Diaulos ............... 115 3.31 Memory Usage - Stress Testing - Diaulos .............. 116 3.32 Garbage Collector Usage - Stress Testing - Diaulos ........ 116 4.1 Programming languages trend (source: GitHub) .......... 118 4.2 Heroku Dashboard - Stadion .................... 133 4.3 Stadion deployed to Heroku ..................... 135 4.4 E2E Tests with Selenium - Stadion ................. 141 4.5 Server Response Time - Load Testing - Stadion .......... 150 4.6 Server Throughput - Load Testing - Stadion ............ 150 4.7 Apdex Score - Load Testing - Stadion ............... 150 4.8 Top Web Transactions - Load Testing - Stadion .......... 151 4.9 Database Response Time - Load Testing - Stadion ........ 152 4.10 Database Throughput - Load Testing - Stadion .......... 152 4.11 Top Database Operations - Load Testing - Stadion ........ 152 4.12 Memory Usage - Load Testing - Stadion .............. 153 4.13 Server Response Time - Stress Testing - Stadion ......... 155 4.14 Server Throughput - Stress Testing - Stadion ........... 155 4.15 Apdex Score - Stress Testing - Stadion ............... 156 vi 4.16 Top Web Transactions - Stress Testing - Stadion ......... 156 4.17 Web Transactions (detail) - Stress Testing - Stadion ....... 157 4.18 Database Response Time - Stress Testing - Stadion ........ 157 4.19 Database Throughput - Stress Testing - Stadion ......... 157 4.20 Top Database Operations - Stress Testing - Stadion ....... 158 4.21 Memory Usage - Stress Testing - Stadion .............. 158 A.1 Git Workflow ............................. 175 D.1 Scrum task board ........................... 188 vii List of Tables 3.1 Spring Modules ............................ 12 3.2 User Simulation - Load Testing - Diaulos ............. 103 3.3 Competition Simulation - Load Testing - Diaulos ......... 103 3.4 Web Transactions - Load Testing - Diaulos ............ 105 3.5 User Simulation - Stress Testing - Diaulos ............. 110 3.6 Competition Simulation - Stress Testing - Diaulos ......... 111 4.1 User simulation - Load Testing - Stadion .............. 148 4.2 Competition simulation - Load Testing - Stadion ......... 149 4.3 Web transactions - Load Testing - Stadion ............. 151 4.4 User Simulation - Stress Testing - Stadion ............. 154 4.5 Competition Simulation - Stress Testing - Stadion ........ 154 4.6 User Simulation - Stress Testing (2 web dynos) .......... 159 4.7 Competition Simulation - Stress Testing (2 web dynos) ...... 159 B.1 Content of MySQL home folder ................... 180 D.1 Quote ................................. 187