Professional Heroku® Programming
Total Page:16
File Type:pdf, Size:1020Kb
ffirs.indd i 1/10/2013 1:46:29 PM PROFESSIONAL HEROKU® PROGRAMMING INTRODUCTION . xxv PART I AN OVERVIEW OF HEROKU CHAPTER 1 How Heroku Works . 3 CHAPTER 2 Architectural Considerations . .17 CHAPTER 3 Porting Your Applications to Heroku . 45 PART II CREATING AND MANAGING HEROKU APPLICATIONS CHAPTER 4 Deploying Your Applications to Heroku . 73 CHAPTER 5 Managing Releases with Heroku . 89 CHAPTER 6 Working with Add-Ons . 115 CHAPTER 7 Managing, Monitoring, and Scaling Your Heroku Applications . 133 PART III USING A DATA STORE WITH YOUR HEROKU APPLICATIONS CHAPTER 8 Using Heroku Postgres as a Data Store for Your Heroku Applications . 157 CHAPTER 9 Using Database.com as a Data Store for Your Heroku Applications . .181 CHAPTER 10 Using Third-Party Data Stores for Your Heroku Applications . .207 PART IV PROGRAMMING ON HEROKU’S POLYGLOT PLATFORM CHAPTER 11 Developing with Ruby . .233 CHAPTER 12 Developing with Java . 267 CHAPTER 13 Developing with Other Supported Languages . 301 CHAPTER 14 Understanding Buildpacks . 351 PART V CREATING A NEW GENERATION OF HEROKU APPLICATIONS CHAPTER 15 Building Mobile Applications with Heroku . 383 CHAPTER 16 Building Social Applications with Heroku . 411 APPENDIX Additional Resources . 445 INDEX . 469 ffirs.indd i 1/10/2013 1:46:29 PM ffirs.indd ii 1/10/2013 1:46:30 PM PROFESSIONAL Heroku® Programming ffirs.indd iii 1/10/2013 1:46:30 PM ffirs.indd iv 1/10/2013 1:46:30 PM PROFESSIONAL Heroku® Programming Chris Kemp Brad Gyger John Wiley & Sons, Ltd. ffirs.indd v 1/10/2013 1:46:30 PM © 2013 John Wiley & Sons, Ltd. Registered offi ce John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom For details of our global editorial offi ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com. The right of the author to be identifi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifi cally disclaim all warranties, including without limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or pro- motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the pub- lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may not be used without written permission. Heroku is a registered trademark of Salesforce.com, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in this book. Heroku product screenshots courtesy of Heroku, Inc. A catalogue record for this book is available from the British Library. 978-1-118-50899-2 (paperback) 978-1-118-50901-2 (ebook) 978-1-118-50902-9 (ebook) 978-1-118-50903-6 (ebook) Set in 9.5 /12 Sabon LT Std Roman, by MPS Limited, Chennai Printed in the United States by Bind-Rite ffirs.indd vi 1/10/2013 1:46:31 PM To my fi ancée, Fiona, whose support and inspiration made writing this book possible; and my parents, Don and Vlasta, who gave me the opportunities throughout my life that made this and all of my achievements possible. —Chris To my wife, Nabila; my son, Cameron; and my parents, Roger and Judy. Without you all this wouldn’t have been possible. —Brad ffirs.indd vii 1/10/2013 1:46:31 PM ffirs.indd viii 1/10/2013 1:46:31 PM ABOUT THE AUTHORS CHRIS KEMP is a cloud architect, innovator, and entrepreneur with experience developing software in a number of languages. The bulk of his development experience is with PHP, Java, and the Salesforce Platform. He started a software development consultancy, Vandelay Enterprises, at the age of 15, developing applications, mostly on the LAMP stack, for customers around the world. Chris then moved to the fast-growing Toronto start-up, I Love Rewards (now Achievers), where he developed rewards and recognition software in PHP and Java, before joining Salesforce.com. Chris currently works out of Salesforce.com’s Toronto offi ce, as a Senior Solution Engineer on the Advanced Technical Solutions team, an international team of trusted pre-sales advisors and architects. He is the worldwide leader of the Heroku Ambassador group, a team of leading Heroku experts in the company. Chris has developed a number of open source projects in Apex and Visualforce, including the wildly popular Cloud Swarm application. He is a named inventor on seven patent applications for innovations developed at Salesforce.com. Chris holds a B.Sc. in Computer Science (Software Engineering specialist, 0T4) from the University of Toronto. BRAD GYGER has extensive experience with various development platforms, including Heroku. Early in his career, he focused on Java application stacks at Sun Microsystems and then Oracle, and later migrated to the cloud, fi rst working at platform provider Engine Yard, and then Heroku. Brad currently leads the Customer Advocacy team at Heroku, where he is tasked with the success of customer applications running on the platform. This requires working knowledge of all supported application architectures, languages, frameworks, and tools within the Heroku universe. He works with customers on a daily basis to ensure that their applications are implemented optimally on the platform. During his career, Brad has worked with thousands of customer applications and made sure each one was as successful as possible. Brad holds a Bachelor of Science degree from Indiana University. He and his family currently reside in the San Francisco Bay Area. ffirs.indd ix 1/10/2013 1:46:31 PM ABOUT THE TECHNICAL EDITOR GREG NOKES has more than 20 years of experience in systems engineering, ranging from designing wide area networks to helping high-traffi c web applications scale successfully. He has successfully lead customer-facing as well as highly technical teams on a variety of projects. He is fl uent in several technologies, including cutting-edge web application servers and deployment tools. Currently, Greg is the Lead Technical Account Manager at Heroku, the premier PaaS provider. In this role, he helps a large and dynamic group of companies learn the best practices for optimizing their applications, as well as assists with technical and architectural advice. Greg enjoys hiking, paintball, and soaking up the surroundings in the beautiful Puget Sound area of the Pacifi c Northwest. ffirs.indd x 1/10/2013 1:46:31 PM CREDITS VP CONSUMER AND TECHNOLOGY PROJECT EDITOR PUBLISHING DIRECTOR John Sleeva Michelle Leete COPY EDITOR ASSOCIATE DIRECTOR—BOOK CONTENT Luann Rouff MANAGEMENT Martin Tribe TECHNICAL EDITOR Greg Nokes ASSOCIATE PUBLISHER Chris Webb PRODUCTION EDITOR Kathleen Wisor ASSISTANT EDITOR Ellie Scott PROOFREADER Nancy Carrasco ASSOCIATE MARKETING DIRECTOR Louise Breinholt INDEXER Jack Lewis MARKETING MANAGER Lorna Mein COVER DESIGNER LeAndra Young SENIOR MARKETING EXECUTIVE Kate Parrett COVER IMAGE © boboling / iStockphoto EDITORIAL MANAGER Jodi Jensen SENIOR PROJECT EDITOR Sara Shlaer ffirs.indd xi 1/10/2013 1:46:31 PM ffirs.indd xii 1/10/2013 1:46:31 PM ACKNOWLEDGMENTS THIS BOOK COULD NOT HAVE BEEN POSSIBLE without the vision and incredible dedication from the uber-smart founders and team at Heroku in developing such an amazing technology and making it better every day. Salesforce.com’s senior leadership team, especially Marc Benioff, must be thanked for bringing Heroku into the Salesforce.com family. The team at Wiley, including Chris Webb, John Sleeva, Luann Rouff, Kate Parrett, Lorna Mein, and Ellie Scott, have done an outstanding job with all the hard work behind the scenes to make this book the best it can be.