Skip to content

haptava/heroku-example

Repository files navigation

Heroku Example App Build Status

Contents

Overview

This example is designed to run a single worker dyno and multiple web dynos.

Overview

Worker Dyno

The worker dyno runs a DynoWatcherServer that:

  • Registers a DynoWatcher MBean with its platform MBeanServer
  • Creates a JmxConnectorLauncher that connects its platform MBeanServer to Haptava as platform@heroku-dyno-watcher-XXXXX (XXXXX is a unique id specific to each Heroku deployment of the heroku-example app)

Web Dyno

Each web dyno runs a Jetty-based PageServer and is initialized with DynoContextListener.

During initialization, each web dyno:

  • Creates a JmxProxyLauncher, which connects its platform MBeanServer to Haptava as platform@heroku-dyno-XXXXX.

  • Starts a JmxProxy on port 8001 that proxies the usergroup@haptava MBeanServer. The usergroup@haptava MBeanServer is on the Haptava server and is available to members of the user group.

  • Starts a JmxProxy on port 8002 that proxies the platform@heroku-dyno-watcher-XXXXX MBeanServer.

  • Creates MXBean proxies for:

  • Registers itself with the DynoWatcherServer, which assigns it a unique name. The DynoWatcher also registers a Dyno MBean for each web dyno.

  • Creates 3 servlets:

Heroku Config Vars

  • HAPTAVA_USERNAME and HAPTAVA_PASSWORD for credentials.
  • APPLICATION_ID is a unique ID used to avoid collisions between users in the same user group running the heroku-example app.

Deploy to Heroku

Deploy

The heroku-example requires a worker dyno to be running, but the "Deploy to Heroku" functionality does not allow starting worker dynos. So after deploying the heroku-example app to your Heroku account, adjust the number of dynos:

  • Go to [Heroku Dashboard] dashboard
  • Go to your newly-deployed heroku-example application
  • Go to the “Resources” page and increase the number of worker dynos to 1 and the number of web dynos to 5.

Install the Heroku toolbelt to control dyno scaling from the CLI and view the dyno logs.

When you finish experimenting with your heroku-example app, make sure you stop all the dynos to avoid charges.

Running the App

Assuming you named your heroku-example app foo, you can reach your app at: https://foo.herokuapp.com.

Click on the "Make Request" button to generate some random requests for the app. For each request you can see:

  • The MBeanServer and MBean invoked during the request
  • The web dyno that handled the request and a summary it recent requests
  • A summary of all the web dynos

You can change the number of web dynos to any number greater than 0, but do not increase the number of worker dynos greater than 1.

The summary page embedded in the default servlet is at: https://foo.herokuapp.com/summary

Web Dyno requests are reset with: https://foo.herokuapp.com/reset

You can view the MBeanServers at: https://api.haptava.io/webdav/MBeanServers/System/Launchers

You can also view the MBeanServers with Java Mission Control by starting a local JmxProxyLauncher.

About

Example of using Haptava with Heroku

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages