Logplex - Request Queue Time

"Request Queue Time is the amount of time between the Heroku Router accepting the request and the web dyno starting to process the request."

Note: We only provide native support for Ruby applications. We recommend using the HireFire - Request Queue Time strategy if you're planning to autoscale a Python or Node.js application. Instructions can be found in the HireFire app when setting up a Dyno Manager using that strategy.

When autoscaling your web dynos based on the Logplex - Request Queue Time strategy, you have to:

  1. Create a logdrain and point it at our secure endpoint:
heroku drains:add https://logdrain.hirefire.io
  1. Once created, take note of the drain token:
heroku drains | grep hirefire

The format of the token is d.00000000-0000-0000-0000-000000000000 .

Ruby Application Integration

To configure your Ruby application to log the request queue time metric:

  1. Add the hirefire-resource gem to your application:
gem "hirefire-resource"
  1. For Rails applications, it automatically injects the required middleware. For other Rack-based applications, like Sinatra or Hanami, manually add the HireFire middleware at the top of the middleware stack in your config.ru file:
use HireFire::Middleware # at the top
# any other middleware here
run MyApp # at the bottom 
  1. Create a HireFire configuration file. In Rails, create an initializer; in other frameworks, create the file where it will be loaded at application boot time. Add the following configuration:
HireFire.configure do |config|
  config.log_queue_metrics = true
  1. Deploy these changes to Heroku.

Non-Ruby Application Integration

For applications written in languages other than Ruby:

1) Write the following format to STDOUT on each HTTP request:

[hirefire:router] queue={TIME}ms

For example:

[hirefire:router] queue=162ms

2) To calculate TIME , use the formula:

current_time_in_milliseconds - X-Request-Start

In Ruby, this is:

(Time.now.to_f * 1000).to_i - env["X-Request-Start"].to_i

Perform the equivalent in your programming language.

Ensure this is done as high up in your web stack as possible on every HTTP request.

After making the necessary changes to your application and setting up the logdrain:

  1. Log in to HireFire and add your Heroku application if you haven't already.
  2. In the application settings, find the field labeled "Logplex Drain Token", add the token, and save.
  3. Create a Dyno Manager (Autoscaler) named web , set the strategy to Logplex - Request Queue Time , configure the autoscaling rules to your liking, save, and enable the manager.

HireFire will then autoscale your web dynos based on the request queue time metric.

If you have any questions or need assistance, do not hesitate to contact us at support@hirefire.io.

Optional Log Filtering

The Logplex strategy requires configuring a log drain from your application to HireFire. HireFire ingests and processes these logs to extract metrics such as service time, connect time, queue time, load, and requests per minute. While we have implemented appropriate security measures and do not retain any sensitive information beyond the necessary metric data, we understand the desire to minimize the volume of log data sent to HireFire. To accommodate this, we offer a Docker image that you can deploy as an application within your Heroku account. This application is designed to ingest logs and forward only the relevant lines, effectively filtering out the majority of the content. Using this filtering service is optional.

For those interested, please visit https://github.com/hirefire/logdrain.proxy for additional details.

Still need help? Contact Us Contact Us