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
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!
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 &
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
!
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
second this. blitz.io is shutting down and we may need a new way to reproduce the benchmark test.