You are previewing Heroku Cloud Application Development.
O'Reilly logo
Heroku Cloud Application Development

Book Description

A comprehensive guide to help you build, deploy, and troubleshoot cloud applications seamlessly using Heroku

In Detail

Heroku is one of the leading cloud platforms supported by several programming languages. It lets you develop applications without worrying about the infrastructure. You can instantly build, deploy, and troubleshoot the most advanced and robust cloud applications using a rich set of available tools. Just write your application and leave the rest to Heroku. Heroku helps you build the most feature-rich web applications using add-ons and multiple data sources that can be easily configured.

This book is about Heroku, but more importantly, it is about the ease with which a developer with limited availability or knowledge of deployment infrastructure can run and manage a cloud app 24/7/365. It will show how Heroku is language independent and does not lock the user to a particular operating environment.

What You Will Learn

  • Recognize the components of the Heroku infrastructure and how they work together to give a seamless platform experience
  • Write an application using any supported language (Ruby, Java, PHP, Python, and more) and deploy it easily and instantly
  • Run and scale your cloud application on demand using a variety of useful Heroku commands
  • Secure and debug your cloud application faster using popular techniques and tools
  • Reuse the provided samples to build agile and robust applications
  • Extend your application features by using simple plugins and add-ons
  • Manage all your applications intuitively using the one-stop Heroku dashboard
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Heroku Cloud Application Development
      1. Table of Contents
      2. Heroku Cloud Application Development
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Hello Heroku
        1. What is cloud computing?
        2. Cloud service models
        3. What is cloud application development?
        4. Key advantages of cloud application development
        5. Introducing Heroku
        6. Walking down the memory lane
        7. An overview of Heroku's architecture
          1. Process management
          2. Logging
          3. HTTP routing
          4. Heroku interfaces
        8. The Heroku feature set
          1. Let's play Heroku
            1. Getting ready for the ride – the prerequisites
            2. Signing up
            3. Installing the Heroku toolbelt
            4. Logging in and generating a new SSH key
        9. Test driving Heroku
        10. Summary
      9. 2. Inside Heroku
        1. The Heroku platform stack
          1. The Celadon Cedar stack
        2. Request routing in Heroku
          1. The execution environment - dynos and the dyno manifold
        3. Heroku's logging infrastructure – the Logplex system
        4. The Heroku add-on architecture
        5. Programmatically consuming Heroku services
          1. The Heroku Platform API
            1. Security
            2. Schema
            3. Data
          2. Accessing the API
            1. API clients
            2. Calling the API
            3. Response
            4. Limits on API calls
        6. The Heroku process architecture
          1. Procfile
          2. Declaring process types
          3. The Procfile format
            1. A sample Procfile
          4. Adding Procfile to Heroku
        7. Running applications locally
        8. Setting local environment variables
        9. Process formation
          1. Process scaling
          2. Stopping a process type
          3. Checking on your processes
            1. Process logs
        10. Running a one-off process
        11. Running anything
        12. Summary
      10. 3. Building Heroku Applications
        1. Heroku's guiding influence – the Twelve-Factor App methodology
          1. A codebase is always versioned and it can have multiple deploys
          2. Declare and isolate dependencies explicitly (always)
          3. Configuration should be stored in the environment
          4. Backend services should be treated as attached (loosely-coupled) resources
          5. Strict separation of the build, release, and run stages of an app
          6. An app in execution is a process or many processes
          7. Services should be exported through port binding
          8. An app should scale out through its process model
          9. Faster startup and graceful shutdown is the way to app agility and scalability
          10. Development and production (and everything in between) should be as similar as possible
          11. The app should just log the event not manage it
          12. App's administrative or management task should be run as a one-off process
        2. Creating a Heroku application
        3. Configuring your Heroku application
          1. The Heroku application configuration API
          2. Examples of using application configuration
            1. The persistence of configuration variables
            2. Accessing configuration variables at runtime
            3. Limits on configuration data
            4. Using the Heroku config plugin
        4. Introducing buildpacks
          1. Using a custom buildpack
          2. Specifying a custom buildpack at the app creation stage
          3. Third-party buildpacks
          4. The buildpack API
          5. Components of a buildpack API
            1. The bin/detect script
            2. The bin/compile script
            3. The bin/release script
          6. Writing a buildpack
        5. The slug compiler
          1. Optimizing the slug
          2. Size limits
        6. Summary
      11. 4. Deploying Heroku Applications
        1. Deployment on Heroku
        2. Getting a Heroku account
        3. Installing the toolbelt client kit
        4. Logging into the Heroku account
          1. Setting up SSH
        5. Writing your application
        6. Pushing your application to Heroku
        7. The Git vocabulary
          1. Getting started with Git
            1. Tracking a new project
            2. Using an existing Git project
            3. The life cycle of an artifact in Git
            4. Tracking files in a Git project
            5. When you don't need Git to track your files
            6. The git diff command – knowing what changed
            7. Committing your changes
            8. Deleting a file
            9. Moving a file
            10. Viewing commit history
            11. Undoing a change
            12. You can use some Git help
          2. The local repository
            1. Remote repositories
        8. Creating a Heroku remote
        9. Renaming an application
        10. Sending code to Heroku
        11. Optimizing slug size
        12. Cloning existing Heroku applications
        13. Forking an application
          1. Side effects of forking an application
        14. Transferring Apps
        15. Optimizing deployments
        16. The choice of a region
        17. Tracking application changes
          1. Setting up Deploy Hooks
            1. Basecamp
            2. Campfire
            3. E-mail
            4. HTTP
            5. IRC
        18. Release management
          1. Checking installed releases
          2. Verifying the new release
          3. Rolling back the release
        19. Summary
      12. 5. Running Heroku Applications
        1. The Heroku app lifecycle
        2. The Heroku CLI
          1. How to get the Heroku client tool
          2. Verifying the tool
          3. How to get the latest Heroku client tool
          4. Where is the Heroku client stored?
            1. What if my client installation is corrupted or not working?
          5. The Heroku CLI commands
          6. Heroku CLI commands by function
          7. Extending the Heroku CLI
          8. The Heroku CLI and add-ons
          9. A note on Heroku CLI and security
        3. Running your cloud apps locally
          1. Using Foreman to check Procfiles
          2. Using Foreman to run apps directly
          3. Running one-off commands
          4. Foreman command-line options
        4. The Apps page
          1. The Resources tab
          2. Managing resources
          3. The Activity tab
          4. The Access tab
          5. The Settings tab
          6. The Run Production Check tab
          7. Heroku support
        5. Summary
      13. 6. Putting It All Together
        1. Heroku's support for Java
          1. General support for Java
          2. Database support for Java apps
          3. Environment configuration
        2. Integrating Eclipse with Heroku
          1. Prerequisites
          2. Configuring Heroku in Eclipse
          3. Installing the Eclipse plugin for Heroku
          4. Setting up Heroku for development
          5. Setting up SSH support
          6. Creating a new Heroku Java app in Eclipse
          7. Using an existing Heroku application
          8. Pushing code to Heroku
          9. Pushing code to the Git repository
        3. Managing Heroku apps in Eclipse
          1. Viewing your Heroku application
            1. Getting to the application's details
            2. Reviewing the application's details
            3. Going deeper into the application information
          2. Adding collaborators to the application
          3. Changing the environment variables
          4. Heroku's process management in Eclipse
          5. Scaling your app dynos
          6. Restarting your web app
        4. Summary
      14. 7. Heroku Best Practices
        1. The One Cloud development platform
          1. Introducing the Cloud 9 IDE
            1. The C9 user interface
            2. The C9 project view
            3. Setting up preferences in the C9 IDE environment
          2. Deploying on Heroku
          3. Performing Git operations using the C9 IDE
        2. Heroku and the data store
        3. Creating a Heroku Postgres database
          1. Logging in to the database
          2. Creating more databases – the fork
          3. Synchronizing databases via database followers
          4. Checking database logs
          5. Performance and the Heroku Postgres database
        4. Disaster recovery in Heroku PostgreSQL
          1. Importing data into Postgres
          2. Deleting a Heroku Postgres database
          3. Accessing Heroku Postgres externally
          4. Accessing the database credentials
          5. Connecting from outside of Heroku
        5. High availability Postgres
          1. Choosing the right plan
        6. When does Heroku Postgres failover?
          1. Effect of the failover
            1. Checking the availability status after failover
        7. Configuring domains the right way
          1. Overview of DNS
          2. Working with DNS in Heroku
            1. Configuring your domain
            2. Domain addition rules
          3. Adding a custom domain to Heroku
          4. Configuring domain DNS
          5. Checking DNS configuration
          6. Removing Heroku custom subdomains
          7. Other domain-related considerations
        8. Optimizing applications
          1. The 2X dyno effect
          2. When do I need the 2X dynos?
          3. Checking whether you need 2X dynos
          4. What if I use 2X dynos?
          5. Now some examples...
          6. Notes on 2X dynos
        9. Managing your app dynos
        10. Using the Heroku scheduler
        11. Using NewRelic to keep the dyno alive
        12. Summary
      15. 8. Heroku Security
        1. Overview
        2. Communication between the developer's machine and the Heroku platform
          1. General concepts of security
          2. Security of developer communication with Heroku
          3. A look inside the SSH protocol
            1. Client authentication
          4. App security and the Heroku dashboard
            1. Your Heroku account and the dashboard
          5. Security of applications and data resident on Heroku and third-party servers
            1. Heroku security practices
            2. Source code security
            3. Build and deploy security
            4. Application security
            5. Data security
            6. Configuration and metadata
            7. Infrastructure security
            8. Security in add-ons
            9. Securing the logging infrastructure
            10. Network security
            11. Security standards and compliance
            12. Securing web requests
            13. Piggyback SSL
            14. SSL for a custom domain
        3. Application security tools
          1. wwwhisper
            1. A sample wwwhisper app
            2. Getting wwwhisper
            3. Removing wwwhisper
            4. Enabling wwwhisper in your application
              1. For other Rack-based applications
            5. Post wwwhisper enablement
            6. Local setup for wwwhisper
            7. Using wwwhisper locally
            8. Disabling wwwhisper in a local environment
          2. Tinfoil website security scanner
            1. Upgrading the add-on
            2. The TINFOILSECURITY_SCAN_SCHEDULE configuration parameter
          3. The Tinfoil security scanner dashboard
          4. The scanning process
        4. Summary
      16. 9. Troubleshooting Heroku Applications
        1. The need for troubleshooting
        2. Your window to the running app – the logs
          1. A little more about Logplex – Heroku's logging system
            1. Sources and drains
            2. The message limit
          2. Retrieving Heroku logs
            1. Getting last 'n' log messages
            2. Getting live log messages
            3. Setting up logging levels
            4. Dissecting the Heroku log message
          3. Log message types
          4. Log filters
            1. Examples of log filtering
          5. Getting more from logging – other logging tools
        3. Techniques for troubleshooting your app
          1. Troubleshooting application downtime
          2. Debugging HTTP requests and APIs
          3. Validating your process formation
          4. Checking your database
          5. When everything else fails
          6. Production check
        4. A recommended Heroku configuration
          1. The stack
          2. The process formation
          3. Database service
          4. Domain and security considerations
          5. Proactive health monitoring
        5. Maintenance windows
          1. Checking the maintenance status
          2. Enabling the maintenance mode
          3. Disabling the maintenance mode
          4. The maintenance window – behind the scenes
          5. Customizing site content
          6. Customizing error pages
          7. Testing custom maintenance and error pages
          8. When requests time out
        6. Error classification in Heroku
        7. Summary
      17. 10. Advanced Heroku Usage
        1. Experimenting with Heroku Labs
          1. Using Heroku Labs features
            1. Seamless deployment using pipelines
            2. Enabling the pipelines feature
            3. Performance monitoring
            4. Switching on monitoring
            5. Log snapshot
            6. Watching your app closely using the Request ID
            7. Supporting the Request ID
        2. Introducing Websockets
          1. Websocket versus HTTP
          2. Websocket is not HTTP
          3. Websocket use cases
          4. Typical apps using Websockets
          5. Supporting Websockets in your app
          6. Establishing a Websocket connection
          7. Disadvantages of using Websockets
        3. Heroku and Websockets
          1. Switching on Websocket support
          2. Turning Websockets off
          3. The Websockets example
            1. The server code
            2. The client code
        4. Your first Heroku Platform API call
          1. Before we get started
          2. Supported API methods
          3. Sample uses of the platform API
          4. Creating an application
            1. Create an application API response
            2. Retrieving application information
            3. Modifying application information
            4. Deleting an application
          5. Interpreting an API response
            1. Error operations
            2. Error format
            3. An example error response
            4. Warnings
        5. Sharing your app on Heroku
          1. Prerequisites for collaboration
            1. Adding app collaborators to the Heroku dashboard
            2. Deleting a collaborator
          2. Adding collaborators via the Heroku CLI
            1. Listing collaborators
            2. Removing a collaborator
          3. Collaborator actions
            1. Working on the app
            2. Viewing the app
        6. Summary
      18. Index