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:
- 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.
- 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.
- Create an init.d script for gor. To support ebextensions’s
ensureRunning, it has to support chkconfig
- The test for whether daemon is installed cannot be just
! rpm -q daemonbut needs to be
/bin/sh -c "! rpm -q daemon"; the
testproperty seems to require a single command to execute
- 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)
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.