Skip to content

Instantly share code, notes, and snippets.

@montanaflynn
Last active January 29, 2021 13:27
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save montanaflynn/01376991f0a3ad07059c to your computer and use it in GitHub Desktop.
Save montanaflynn/01376991f0a3ad07059c to your computer and use it in GitHub Desktop.
Kong Benchmark Setup

To reproduce Kong's benchmark please follow these instructions.

Create AWS Instances

Spin up three m3.medium EC2 ubuntu 14.04 instances with public DNS enabled and configure them for high network traffic by increasing these limits:

Added fs.file-max=80000 to /etc/sysctl.conf

Added the following lines to /etc/security/limits.conf

*          soft     nproc          80000
*          hard     nproc          80000
*          soft     nofile         80000
*          hard     nofile         80000

Cassandra Server Setup

SSH into one of your servers to install Cassandra to act as Kong's datastore.

wget http://apache.mirrors.tds.net/cassandra/2.1.5/apache-cassandra-2.1.5-bin.tar.gz
tar xvzf apache-cassandra-2.1.5-bin.tar.gz
./apache-cassandra-2.1.5/bin/cassandra

Cassandra is now running!

Lwan Server Setup

SSH into another one of the servers to create a high performance hello world API to test against.

apt-get update && apt-get install git cmake zlib1g-dev pkg-config lua5.1-dev libsqlite3-dev libmysql++-dev
git clone git://github.com/lpereira/lwan

Now we can build lwan!

cd lwan
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Now replace lwan/lwan.conf with the following:

keep_alive_timeout = 15
quiet = false
reuse_port = false
expires = 1M 1w
threads = 0

listener *:8080 {
    prefix /hello {
            handler = hello_world
    }
}

Finally you can start lwan!

cd lwan
nohup ./lwan &

Kong Server Setup

SSH into the last instance and set up Kong for benchmarking against.

wget https://github.com/Mashape/kong/releases/download/0.2.0-2/kong-0.2.0-2.trusty_all.deb
sudo apt-get update
dpkg -i kong-0.2.0-2.*.deb
sudo apt-get install -f

Open /etc/kong/kong.yml with your favorite editor (vi or nano work well) and update the databases_available section with your Cassandra host:

# Databases configuration
databases_available:
  cassandra:
    properties:
      hosts: "YOUR_CASSANDA_INSTANCE.compute-1.amazonaws.com"

And finally add a route for blitz.io verification inside the proxy server block:

server {
  listen {{proxy_port}};
  ...
  
  location /robots.txt {
    return 200 'User-agent: *\nDisallow: /';
  }
  
  # Add this location block for verifying blitz.io
  location  /mu-f279ec87-3b23663b-25c08e12-b1135ac0  {
    return 200 '42';
  }
  ...
}

Now kong start should connect to Cassandra and run it's migrations. Now let's add the API, make sure to replace the target URL with the public DNS of your API server.

curl -i -X POST \
 --url http://localhost:8001/apis/ \
 --data 'name=mockbin' \
 --data 'target_url=PUBLIC_API_DNS.amazonaws.com:8080' \
 --data 'public_dns=test.api'

Should return a 201 created. Verify it's working by making a request through Kong:

curl -H "host:test.api" localhost:8000

Which should return hello world!

Blitz.io

We used blitz.io to produce the load test and generate pretty charts. Sign up at blitz.io and add your Kong public DNS to verify. Create a test going from 1 to 2000 connections and add host: test.api using --header select option under advanced options.

Run the test! Feel free to report back here with the results :D

@molnarp
Copy link

molnarp commented Apr 19, 2017

As it is, this is just a measurement with nothing to compare against. Is there a baseline without Kong?

@molnarp
Copy link

molnarp commented Apr 19, 2017

Here it is: Kong/kong#2303

@mwaaas
Copy link

mwaaas commented Oct 14, 2017

blitz.io is shutting down. Should come with new reproduce instructions.

@humbleProgram
Copy link

humbleProgram commented Feb 14, 2018

second this. blitz.io is shutting down and we may need a new way to reproduce the benchmark test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment