Skip to main content

GoReplay - Testing Your Site with Actual Traffic

Goal: 
In these article we gonna learn How to capture your Real Time traffic from production and reuse it at your testing/development environment.

Prerequisite:
One web server running, or If you are just playing around then you can run goreplay test ftp server.

Let's Begin
Load Testing for site serving millions user wasn't be that easy before I came to know GoReplay. Here I am not gonna explain you How great go replay is, You will automatically get to know after following steps above step to capture and replay your request logs. FYI GoReplay capture logs from tcpdump.

Installation:
Download zip file from there git repo and unzip it.
#create a directory
mkdir ~/goreplay
#go to directory you created
cd ~/goreplay
#download tar file from goreplay git repo
wget https://github.com/buger/goreplay/releases/download/v0.16.1/gor_0.16.1_x64.tar.gz
#unzip it
tar -xf gor_0.16.1_x64.tar.gz

After Unzipping Check GoReplay binary File is available in directory.

Capture Request:
It will basically capture request coming on port 80 on that server.
sudo ./goreplay --input-raw :80 --output-file filename --exit-after 5m 

This command will basically capture request coming on port 80 and store that data into filename and will stop capturing after 5 minutes.

Replay Request:
It will basically replay same traffic on testing machine.
sudo ./goreplay --input-file filename --output-http "http://domain.com/"

This command will basically hit request that's already stored in filename to given http domain.

Conclusion:
Yes, I told to you Testing your development site with actual production requests wasn't that easy.

For Further Reading, please check following Links

GoReplay Documentation
https://github.com/buger/goreplay/wiki/Getting-Started

A Blog on medium by Leonid Bugaev
https://leonsbox.com/goreplay-v0-16-and-4th-anniversary-5408b1fd72e0

Comments

Popular posts from this blog

Curator

Goal: In these tutorial we gonna cover deletion of old logs in ELK Stack. We gonna achive these by deleting old indices created by Logstash while dumping logs in Elasticsearch. Prerequisites: Old logs to delete... 😜😜 Let's Begin the exercise: Install curator Curator is a package in Elasticsearch  repository to delete old indices. Create a file sudo vi /etc/yum.repos.d/curator.repo paste following lines Save and Exit file Run yum install sudo yum install elasticsearch-curator Configure Curator Create a directory mkdir ~/.curator/ Open a file sudo vi ~/.curator/curator.yml paste following code Save and Exit file Deletion pattern Create file to define delete pattern in Elasticesearch sudo vi ~/.curator/delete_indices.yml paste following lines in file Create a log file for curator on the location you defined in configuration, and assign permission to right into file. sudo touch /var/log/curator #to assign permission to write l

Elastalert

Goal Trigger alert on elastic search stream.   Install Elastalert sudo yum install gcc sudo pip install elastalert sudo yum install git Just to get basic elastalert rules reference clone following git repository. git clone https://github.com/Yelp/elastalert.git example_elastalert Create your own rules sudo mkdir -p /etc/elastalert/rules_folder/ sudo cp ~/example_elastalert/example_rules/example_frequency.yaml /etc/elastalert/rules_folder/frequency.yaml sudo cp ~/example_elastalert/config.yaml.example /etc/elastalert/config.yaml Configure Elastalert sudo vi /etc/elastalert/config.yaml Search for 'rules_folder', 'es_host' and change values in file rules_folder: "/etc/elastalert/rules_folder" es_host: localhost Now Open File  and change conf sudo vi /etc/elastalert/rules_folder/frequency.yaml filter: - term: _type: "apache-error" - query: query_string: query: "host:HostName" alert: - "email" include: [