The Holy Java

Building the right thing, building it right, fast

Running Gor, the HTTP traffic replayer, as a service on AWS Elastic Beanstalk

Posted by Jakub Holý on July 30, 2015

Gor is a great utility for replicating (a subset of) production traffic to a staging/test environment. Running it on AWS Elastic Beanstalk (EB) has some challenges, mainly that it doesn’t support running as a daemon and that there isn’t any documentation/examples for doing this. Well, here is a solution:


  1. We want to run Gor as a service (instead of just a background + nohup command) because that is the only way to ensure it will keep running even as EB adds and removes nodes.
  2. Use the daemon utility to run Gor as a daemon (which it does not support out of the box). Daemon is small and works well. It will ignore gor’s output and automatically restart it if it dies.
  3. Create an init.d script for gor. To support ebextensions’s ensureRunning, it has to support chkconfig
  4. The test for whether daemon is installed cannot be just ! rpm -q daemon but needs to be /bin/sh -c "! rpm -q daemon"; the test property seems to require a single command to execute
  5. The files are downloaded from a private S3 bucket (which needs to be accessible by the EC2 role used and have the policy to allow access to the files in question)

Side note

I originally wanted to run Gor only on a single node using a container_command with leader_only to enable it on just that node. However that does not work because this is only run when the app is deployed but not when autoscaling adds new nodes (f.ex. after killing some old ones – typically starting with the leader). The new nodes are somewhat cloned from the existing ones, so they have the package, service, etc., but the command does not run there. And there is no “leader” concept outside of the EB deployment process. So the only option is to run Gor on all the nodes.

Sorry, the comment form is closed at this time.

%d bloggers like this: