We skipped the beta,
deployed once,
everybody signed up,
and never had a problem.'
- No one ever
Scaling API's is about:
Performance is about:
Scaling API's is about:
Performance is about:
Fullstack JS, DevOps, Freelancer, Digital Nomad.
bigSmall.io Micro-Consulting Platform
Unit testing = feature confidence for changes
Performance testing = feature confidence for # of users
Performance testing came from Enterprise software (don't google "example test plan")
Agile Performance Testing means leaner, smaller, and iterative
Can I make this use case faster? In 2 weeks.
Can each server to serve 1000 requests/second, without crashing or errors? In 2 weeks.
We have a marketing event. App must serve 70,000 requests/second. In 2 weeks.
Measure
Change
Predict
In 2 weeks.
Load testing
How long does it take to process 10,000 requests?
Endurance/Soak testing
Measure resource leaks over sustained use.
How often will the server "randomly" crash?
Stress testing
Upper performance limit before failure.
Can it support 10,000 users simultaneously?
Spike testing
Sudden increased load and measures results.
Slashdot effect testing
https://github.com/MichaelJCole/evil_kittens
Text
GET /tiny-kittens-in-your-memory/:id -> text/plain: filename
GET /big-kittens-in-your-memory/:id -> image/jpeg: [kitten jpg data]
GET /evil-kittens-in-your-memory/:id -> lock 1 mb of memory for 1 sec
GET /evil-kittens-in-your-cpu/:id -> Calculate fib(30) badly
GET /evil-kittens-in-your-disk/:id -> writes 1 mb to disk
GET /evil-kittens-in-your-network/:id -> sends 512k of random data
Text
https://github.com/MichaelJCole/evil_kittens
# If you'd like to play along on your laptop:
# google `github evil_kittens`
# Get the code
git clone git@github.com:MichaelJCole/evil_kittens.git
cd evil_kittens
# Install dependencies
npm install
# Start server
node single.js
# Make requests
curl http://localhost:8000/evil-kittens-in-your-cpu/hello
wget -qO- http://localhost:8000/evil-kittens-in-your-cpu/hello
Text
https://github.com/MichaelJCole/evil_kittens
# Install ApacheBench
sudo apt-get install apache2-utils
# MEASURE: -n 1000 requests, using -c 10 threads, -l to relax
node single.js
ab -l -n 1000 -c 10 http://localhost:8000/evil-kittens-in-your-cpu/single
# Hmmmm... How could it be faster? Lets turn off logging
node singleNoLog.js
ab -l -n 1000 -c 10 http://localhost:8000/evil-kittens-in-your-cpu/single
# Hmmmn... What if we used the cluster api?
node cluster.js
ab -l -n 1000 -c 10 http://localhost:8000/evil-kittens-in-your-cpu/single
# Yes!
# MEASURE 10000 requests with 1mb memory leak.
node single.js
ab -l -n 10000 -c 10 \
http://localhost:8000/evil-kittens-in-your-memory/single
# MEASURE 10000 requests with 1mb memory leak.
node single.js
ab -l -n 10000 -c 10 \
http://localhost:8000/evil-kittens-in-your-memory/single
My laptop has 16 gig of memory.
The "cloud" usually has about 0.5 -> 2 gig.
It's important to test on localhost and in a production-like environment - aka "stage".
If we use `ab` to test staging, all the requests come from localhost. We need some new tools.
READER BEWARE:
"evil kittens" could be considered a denial-of-service attack, ESPECIALLY a shared hosting provider like Heroku.
Inappropriate use could cause others, and you, great suffering in downtime, account lock-outs, and/or legal aggression.
aka. Don't come cryin to me!
READER BEWARE:
"evil kittens" could be considered a denial-of-service attack, ESPECIALLY a shared hosting provider like Heroku.
Inappropriate use could cause others, and you, great suffering in downtime, account lock-outs, and/or legal aggression.
(and for my final trick of the evening)
# Deploy your app.
git push heroku
# Install beeswithmachineguns
pip install git+git://github.com/newsapps/beeswithmachineguns.git
# make a ~/.boto file with your AWS keys.
# Details: https://github.com/newsapps/beeswithmachineguns
# I did this already because it is really slow!
bees up -s 8 -g public -k evilkittens -z us-east-1e
# Wait till bees are no longer "Initailizing" in AWS console.
bees report
# Do the test
bees attack -n 10000 -c 40 \
-u https://evilkittens.herokuapp.com/tiny-kittens-in-your-memory/bees
# forget this and you will get a big bill.
bees down
Measure
Change
Predict
In 2 weeks.
bigSmall.io Micro-Consulting Platform