Java EE 7 Performance Tuning and Optimization
Total Page:16
File Type:pdf, Size:1020Kb
Java EE 7 Performance Tuning and Optimization Boost the efficiency of your enterprise applications by performance tuning and optimization with Java Osama Oransa BIRMINGHAM - MUMBAI Java EE 7 Performance Tuning and Optimization Copyright © 2014 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: June 2014 Production reference: 1160614 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78217-642-8 www.packtpub.com Cover image by Sean FitzGerald ([email protected]) Credits Author Project Coordinator Osama Oransa Priyanka Goel Reviewers Proofreaders E.P. Ramakrishnan Simran Bhogal Chirag Sangani Maria Gould Deepak Vohra Ameesha Green Jeff Zhang Paul Hindle Commissioning Editor Indexers Mary Jasmine Nadar Mehreen Deshmukh Rekha Nair Acquisition Editor Tejal Soni Nikhil Karkal Priya Subramani Content Development Editor Graphics Dayan Hyames Sheetal Aute Ronak Dhruv Technical Editors Disha Haria Novina Kewalramani Abhinash Sahu Humera Shaikh Production Coordinator Copy Editors Manu Joseph Alisha Aranha Roshni Banerjee Cover Work Adithi Shetty Manu Joseph About the Author Osama Oransa is an IT solution architect with more than 12 years of solid technical experience in Java EE. He is a certified Java enterprise architect and an SME in web services technology. He has worked for most of the key players in the IT industry, such as IBM, Oracle, and Hewlett Packard. He previously worked as a performance consultant at DevFactory, and he is currently working with the Vodafone Group as a solution architect. He has also participated in establishing Pulse Corp as a medical software services company in Egypt. He has a diploma in IT from the Information Technology Institute (ITI) and a diploma in CS from the Arab Academy for Science, Technology and Maritime Transport (AASTM). He is currently working towards a Master's degree in CS. Being from Cairo, he is a frequent speaker at the Java Developer Conference (JDC) in Cairo. In 2010, one of his projects in Pulse Corp, "Health Intact", won Oracle Duke's Choice Award. He is the founder of more than 12 open source projects hosted on SourceForge. He has also been selected by Oracle for the future of the Java campaign for his valuable contribution to the industry. He is a volunteer Java technology evangelist who gives technical sessions at different companies, conferences, and on blogs. His technical blog can be found at http://osama-oransa.blogspot.com/. Acknowledgments After more than 17 years since my first IT book on the Assembly language, I got the chance to write my second book. It was really a nice experience to deal with the wonderful people at Packt Publishing. After thanking my God, I would like to thank my parents and my wife for their full support while writing this book. Special thanks to Reshma Raman, the Author Acquisition Executive who contacted me to write this book. I would like to thank Priyanka Goel, the Project Coordinator who helped me to deliver the book following the agreed timeline and who gave me her full support. I would like to thank Nikhil Karkal, the Acquisition Editor, for his support in the early, critical phases of the book and his continuous efforts in providing me with the proper guidelines. I would like to thank Dayan Hyames, the Lead Technical Editor, for his efforts in reviewing the content of this book and guiding me to provide the best outcome. I would like to thank the technical reviewers E.P. Ramakrishnan, Chirag Sangani, Deepak Vohra, and Jeff Zhang, who caught my errors and provided me with very constructive and valuable comments to enhance the content of this book. I would like to thank the technical editors Novina Kewalramani and Humera Shaikh for their tremendous efforts in the book. Finally, thanks goes to all the people who participated in this book who I don't know by name—without you, this book wouldn't see the light. Thank you! About the Reviewers E.P. Ramakrishnan is an enthusiastic developer and a technical writer. He earned his postgraduate degree in Computer Science and Engineering from Anna University, Tamil Nadu, India. He has a steady industry exposure of 6 years. His areas of expertise include Java Server Faces (JSF), the Java Persistence API, CDI, RESTful Services, Swings, Tomcat Clustering, and load balancing. Also, his areas of interest are Linux, Android, and systems security. Besides development, his major interest lies in writing technical blogs which simplify the latest technologies for beginners. You are welcome to visit his blog at http://www.ramkitech.com and give your feedback. He can be reached at [email protected]. Chirag Sangani is a computer scientist living in the Seattle area. He holds an MS degree in Computer Science from Stanford University and a B.Tech degree in Computer Science and Engineering from the Indian Institute of Technology, Kanpur. An exposure to computers since his early childhood has allowed Chirag to explore his varied interests while witnessing the birth of the Internet. He has dedicated the last 10 years to perfecting his skills while simultaneously diving deep into computer science theory. He has had varied interests and experiences—from computer architecture to networking, distributed systems to machine learning and data mining, complexity theory to cryptography, and mobile and web development to 3D game design. He has found that merging different fields of computer science allows for a holistic approach towards solving any problem. He currently works for Microsoft. Deepak Vohra is a consultant and a principal member of the NuBean.com software company. He is a Sun certified Java programmer and web component developer, and he has worked in the fields of XML, Java programming, and Java EE for over 5 years. Deepak is the co-author of the Apress book Pro XML Development with Java Technology, and he is the technical reviewer for the O'Reilly book WebLogic: The Definitive Guide. He is also the technical reviewer for the Course Technology PTR book Ruby Programming for the Absolute Beginner. He is also the author of the Packt Publishing books JDBC 4.0 and Oracle JDeveloper for J2EE Development, Processing XML Documents with Oracle JDeveloper 11g, EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g, and Java EE Development with Eclipse IDE. Jeff Zhang started working with middleware software in 2002. He joined IONA and worked on Corba and web service products. In 2008, Jeff entered Redhat and became core developer of the JBossAS team. After more than 10 years of working on middleware, Jeff has learned a lot about application servers, PAAS, containers, and services. He believes that mobile technology and the Internet will change people's lives. I would like to thank the author who has written a great book. Thanks goes to Priyanka Goel and Aurita D'souza for their help in the reviewing stage. Thanks also goes to my wife and my son—your support is most important. www.PacktPub.com Support files, eBooks, discount offers, and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. To my dear parents, the owners of all my life achievements. To my lovely wife, Rasha, the angel of my life. To my diamond daughters—the best gifts in my life—Judy and Kenzy. –Osama Oransa Table of Contents Preface 1 Chapter 1: Getting Started with Performance Tuning 9 Understanding the art of performance tuning 10 Understanding performance issues 12 Classifying performance issues by the discovery phase 13 Requirement phase and design-time issues 14 Development-time issues 15 Testing-time