Wiley
Wiley.com
Print this page Share

Professional Heroku Programming

ISBN: 978-1-118-50899-2
522 pages
February 2013
Professional Heroku Programming (1118508998) cover image

A complete guide to building and deploying web apps with Heroku

A cloud application platform, Heroku is currently the only approved platform for creating apps within Facebook, and its number of users is growing at rapid pace. However, there are very few books on the market that offer professional-level coverage of this platform, until now. The author duo begins with an introduction to the Heroku platform and its associated core concepts and then goes on to explain how writing for this platform differs from that of traditional development systems. Example applications, additional resources, and advice for your next steps round out this resource, making it a thorough, indispensable guide.

  • Features information not found anywhere else, as both authors work for Heroku
  • Explains the inner workings of Heroku with special emphasis placed on building web and mobile applications
  • Introduces GIT-based development workflow and the process model within the Heroku platform
  • Details coding, building, deploying, and scaling effectively using the Heroku tool base

Providing you with fully functional code and downloadable code examples, Professional Heroku Programming is your complete guide to mastering this platform.

See More

INTRODUCTION xxv

PART I: AN OVERVIEW OF HEROKU

CHAPTER 1: HOW HEROKU WORKS 3

How the Stacks Stack Up 4

Understanding Dynos and the Dyno Manifold 6

Understanding Dyno Isolation 8

Exploring the Process Model 8

Understanding Erosion Resistance 10

Managing Version Control 11

Understanding the Slug Compiler 12

Routing HTTP Requests 13

Summary 15

CHAPTER 2: ARCHITECTURAL CONSIDERATIONS 17

Building Twelve-Factor Applications 18

Managing Your Application Portfolio with Pace Layering 21

Systems of Record 21

Systems of Differentiation 21

Systems of Innovation 22

Classification 22

Security and Reliability 22

Governance 23

Application Portfolio Management 23

Ensuring Security and Compliance 25

Physical Security and Safeguards 25

Network Security 25

Dyno- and Stack-Layer Security 26

Data Retention 27

Dealing with Security Issues 27

Certifications, Accreditations, and Compliance 27

Understanding Redundancy and Reliability 28

Disaster Recovery and Availability Zones 28

Availability and Transparency 29

Securing Your Heroku Application 31

Use a Strong Password for Your Heroku Account 31

Encrypt All Data in Transit 32

Encrypt Sensitive Data at Rest 32

Use Best Practices for Secure Development 32

Don’t Reinvent the Wheel 32

Verify Security and Compliance Needs with

Third-Party Providers 32

Monitor Your Application’s Logs 33

Encrypting Communications with SSL 33

Piggybacking on Heroku’s SSL Certificate 33

Using SSL Endpoint 34

Storing Static Assets and Using CDNs 36

Storing Static Assets on Amazon S3 36

Speeding Up International Applications with Amazon CloudFront 41

Summary 43

CHAPTER 3: PORTING YOUR APPLICATIONS TO HEROKU 45

Understanding Differences from Traditional Filesystems 46

Ephemeral Filesystems 47

Multi-Dyno Applications 47

Considerations for Porting Existing Applications 47

Choosing a Data Store 48

Using Heroku Postgres as a Data Store 48

Using Database.com as a Data Store 49

Using Add-On Data Stores 50

Using a Third-Party Data-as-a-Service Provider 50

Using Multiple Data Stores 51

Considerations for Porting Existing Applications 51

Managing Sessions 51

Understanding Caching 52

Storing Static Assets 54

Managing Configuration Variables 54

Replacing Web Servers and Containers 55

Managing Dependencies 56

E-Mailing from Your Application 57

Running Cron Jobs 57

Understanding Logging 59

Relying on External Programs 61

Scaling Up versus Scaling Out 62

Binding to Ports 62

Managing Long-Running Processes 63

Shutting Down Gracefully 65

Moving Your Domain 66

HTTPS over SSL 66

Considerations for Porting Existing Applications 67

Summary 68

PART II: CREATING AND MANAGING HEROKU APPLICATIONS

CHAPTER 4: DEPLOYING YOUR APPLICATIONS TO HEROKU 73

Installing the Heroku Toolbelt 73

Git 74

Foreman 75

The Heroku Client 76

Interacting with Heroku via the Command-Line Interface 77

The Magic of git push 79

Post Deploy Hooks 80

Navigating the Heroku Dashboard 80

Changing Your Application’s Name 82

Adding Custom Domains 83

Adding Custom Collaborators 83

Scaling Resources 84

Summary 87

CHAPTER 5: MANAGING RELEASES WITH HEROKU 89

Managing Multiple Environments 90

Managing Configuration Variables 94

Securing Development Environments 97

Versioning and Rolling Back Releases 100

Using Deploy Hooks 102

Managing Planned Downtime and Custom Error Pages 103

Implementing Continuous Integration 107

Summary 114

CHAPTER 6: WORKING WITH ADD-ONS 115

The Heroku Add-On Ecosystem 116

Architectural Considerations 117

Exploring Popular Add-Ons 117

SQL-Based Data Stores 118

NoSQL-Based Data Stores 118

Search 119

Logging and Monitoring 120

Installing Add-Ons 121

Installing Add-Ons from the Heroku Dashboard 122

Installing Add-Ons from the Command-Line Interface 125

Creating Add-Ons 127

Summary 131

CHAPTER 7: MANAGING, MONITORING, AND SCALING YOUR HEROKU APPLICATIONS 133

Adding Custom Domains 133

Viewing Logs and Associated Tools 136

Managing and Tuning Performance 140

Performance Management with New Relic 141

Performance Tuning Guidelines 145

Leveraging the Heroku API 145

Administration Options 146

Mobile 146

Multi-Accounts 149

Heroku Manager 150

Summary 153

PART III: USING A DATA STORE WITH YOUR HEROKU APPLICATIONS

CHAPTER 8: USING HEROKU POSTGRES AS A DATA STORE FOR YOUR HEROKU APPLICATIONS 157

Getting Started with Heroku Postgres 159

Understanding Continuous Protection 159

Understanding Automated Health Checks 160

Creating a Higher-Availability Database Architecture 160

Creating Databases 161

Forking Databases 164

Creating Database Followers 164

Managing Databases 166

Monitoring Databases 166

Choosing the Right Plan 167

Deleting Databases 168

Backing Up Data 169

Importing Data 171

Using Advanced Features 173

Sharing Information with Data Clips 173

Using hstore for Schema-Free Data Storage 174

Cancelling Queries 176

Creating a Sample App 176

Summary 179

CHAPTER 9: USING DATABASE.COM AS A DATA STORE FOR YOUR HEROKU APPLICATIONS 181

Getting Started with Database.com 182

Creating a Database 183

Importing and Exporting Data 188

Managing Your Database 191

Creating a Sample Application 193

Managing Users 198

Authenticating Users 198

Using Advanced Features 199

Understanding Profiles and Sharing 199

Enforcing Data Integrity with Validation Rules 200

Automating with Workflow Rules 201

Managing Change with Test Databases 202

Storing Files 203

Automating with Apex Triggers 203

Leveraging Social Graphs 204

Summary 204

CHAPTER 10: USING THIRD-PARTY DATA STORES FOR YOUR HEROKU APPLICATIONS 207

SQL-Based Options 207

MySQL 208

Alternative Postgres — JustOneDB 215

NoSQL-Based Options 217

MongoDB 218

Redis 220

Apache Cassandra 222

Apache CouchDB 224

Attaching Existing Data Stores 226

Summary 229

PART IV: PROGRAMMING ON HEROKU’S POLYGLOT PLATFORM

CHAPTER 11: DEVELOPING WITH RUBY 233

Understanding Ruby 234

Installing Ruby on Your Local Workstation 234

Managing Dependencies 235

Creating an Application with the Rails Framework 238

Writing the Application 238

Signing Up for a Twilio Account 244

Deploying the Application to Heroku 244

Testing the Application 247

Creating an Application with the Sinatra Framework 248

Writing the Application 248

Deploying the Application to Heroku 251

Testing the Application 253

Using Delayed Job for Background Jobs 253

Setting Up Delayed Job 255

Deploying the Application to Heroku 257

Testing Delayed Job 258

Caching with Ruby 261

Porting Ruby Applications to Heroku 263

Summary 265

CHAPTER 12: DEVELOPING WITH JAVA 267

Understanding Java 268

Writing Enterprise Applications on Heroku 268

Installing the Java Development Kit 271

Installing on Windows 271

Installing on Mac OS X 272

Installing on Linux 272

Managing Dependencies 272

Writing a Containerless Application with Embedded Jetty 275

Writing an Application with the Spring Framework

and Hibernate on Tomcat 281

Writing an Application with the Play Framework 286

Deploying a WAR File Directly to Heroku 294

Additional Considerations 295

Porting Java Applications to Heroku 296

Session Management and Caching 297

Memory Management 298

Continuous Integration 298

Summary 298

CHAPTER 13: DEVELOPING WITH OTHER SUPPORTED LANGUAGES 301

Developing with Python 302

Additional Considerations 309

Developing with Node.js 311

Additional Considerations 317

Developing with Clojure 319

Additional Considerations 326

Developing with Scala 328

Additional Considerations 334

Developing with Groovy Using the Grails Framework 336

Additional Considerations 341

Developing Non-Facebook Applications on PHP 343

Additional Considerations 346

Summary 349

CHAPTER 14: UNDERSTANDING BUILDPACKS 351

How Buildpacks Work 352

bin/detect 353

bin/compile 353

bin/release 358

Developing .NET Applications on Heroku 359

Developing Perl Applications on Heroku 362

Packaging Binary Buildpack Dependencies 366

Creating Custom Buildpacks 370

Building the Blassic Binary on Vulcan 370

Creating the Build Scripts 373

Pushing Your Buildpack to a Public Git Repository 376

Creating and Deploying Your Application to Heroku 377

Summary 380

PART V: CREATING A NEW GENERATION OF HEROKU APPLICATIONS

CHAPTER 15: BUILDING MOBILE APPLICATIONS WITH HEROKU 383

Understanding Mobile Development Architectures 384

Native Mobile Applications 384

HTML5 Mobile Applications 386

Hybrid Mobile Applications 387

Using a Central Data Repository for Mobile Applications 388

Writing an HTML5 Mobile Application 389

Creating the Back End 390

Creating the Front End 394

Using Toolkits and Add-Ons for Mobile Application Development 405

StackMob 405

Parse 406

RhoConnect 407

PubNub 409

BoxCar 409

Summary 409

CHAPTER 16: BUILDING SOCIAL APPLICATIONS WITH HEROKU 411

Writing Facebook Applications with PHP 412

Creating a Facebook Canvas Application 412

Writing the Contest App Code 416

Deploying the Application to Heroku 424

Making Heroku Applications Social with the Chatter API 429

Creating a Shadow Object in Database.com 430

Summary 444

APPENDIX: ADDITIONAL RESOURCES 445

The Heroku Website 445

The Heroku Dev Center 446

Professional Heroku Programming’s GitHub Repository 447

Log a Ticket with Heroku Support 447

Heroku Ninja 448

Heroku Java 449

Stack Overfl ow 450

Heroku Community Google Group 451

Heroku IRC Channel 451

Heroku’s Twitter Accounts 452

Heroku’s Offi cial Blog 453

Heroku News 454

Heroku on Facebook 455

Heroku Status 455

Heroku Postgres 456

Heroku Add-Ons 457

Heroku Add-On Provider Site 458

Database.com User Guide 459

Developer Force Integration 460

Force.com Discussion Boards 461

Heroku API Documentation 462

Heroku Partners 463

Heroku Beta Program Sign-Up 464

Heroku Success Stories 464

Heroku on Vimeo 465

Heroku Waza 466

The Twelve-Factor App 467

James Ward’s Blog 468

INDEX 469

See More

Chris Kemp is on the Salesforce.com Advanced Technical Solutions team. He is the global leader of the Heroku expert group and is generally acknowledged to be one of the leading Heroku experts at Salesforce.com.

Brad Gyger is the Manager of the Customer Advocacy Team at Heroku. He and his team are tasked with ensuring that all users are able to optimize their experience on the Heroku platform.

See More
Download TitleSizeDownload
ReadMe File 868 bytes Click to Download
Full Code Download 1.52 MB Click to Download
Chapter 5 3.61 KB Click to Download
Chapter 8 40.72 KB Click to Download
Chapter 9 37.82 KB Click to Download
Chapter 11 85.73 KB Click to Download
Chapter 12 243.85 KB Click to Download
Chapter 13 612.16 KB Click to Download
Chapter 14 3.88 KB Click to Download
Chapter 15 736.69 KB Click to Download
Chapter 16 136.42 KB Click to Download
See More
Back to Top