Benchmarking with
NGINX
Introduced by Owen Garrett
Presented by Rick Nelson
Nginx, Inc.
Slide 2
Slide 2 text
About this webinar
When you want to know how many resources to allocate for your
NGINX servers or what the capacity of your current NGINX servers is,
you need to be able to perform proper benchmark testing, but this
can be complicated. In this webinar, you'll learn the considerations
that need to go into planning, configuring and running benchmarks.
Slide 3
Slide 3 text
Agenda
• Introduc)on
• Common
Pi/alls
• Tips
and
Techniques
• Demonstra)on
• Ques)ons
Slide 4
Slide 4 text
INTRODUCTION
Slide 5
Slide 5 text
What is NGINX?
Internet
N
Web Server
Serve content from disk
Application Server
FastCGI, uWSGI, Passenger…
Proxy
Caching, Load Balancing… HTTP traffic
þ Application Acceleration
þ SSL and SPDY termination
þ Performance Monitoring
þ High Availability
Advanced Features: þ Bandwidth Management
þ Content-based Routing
þ Request Manipulation
þ Response Rewriting
þ Authentication
þ Video Delivery
þ Mail Proxy
þ GeoLocation
Slide 6
Slide 6 text
Why do Benchmarking?
• Stress
test
• Capacity
planning
• Comparison
tes)ng
(bake
off)
Slide 7
Slide 7 text
Benchmarking Considerations
• It’s
complicated
• What
is
the
goal?
• What
kind
of
test
environment
do
you
have?
• What
tes)ng
tools
do
you
have?
• How
well
can
you
simulate
produc)on
traffic?
Slide 8
Slide 8 text
What areas are you testing?
• Web
server
• Applica)on
Server
• Reverse
Proxy
• All
of
the
above
Slide 9
Slide 9 text
What are you testing?
• Can
you
simulate
produc)on
traffic?
• If
not,
what
are
you
concerned
about:
– Connec)ons
– Request
rate
– Bandwidth
– SSL
– All
of
the
Above
Slide 10
Slide 10 text
What are you testing?
• Can
you
do
a
full
produc)on
test?
• If
not,
do
a
smaller
scale
test
and
extrapolate
• Know
your
traffic
– Get
vs.
Post,
request/response
sizes,
etc.
• What
you
need
to
test
vs.
what
you
are
actually
tes)ng
Slide 11
Slide 11 text
What are you testing?
• You
may
want
to
test
a
single
variable
– Connec)ons
– Request
rate
– Bandwidth
– New
SSL
handshakes
Slide 12
Slide 12 text
Test Environment
• You
are
always
tes)ng
the
whole
environment
– Tes)ng
Tools
• Load
generators
• Web
Servers
– Systems
under
Test
(SUT)
• Reverse
proxies
• Web
servers
Slide 13
Slide 13 text
Test Environment
• Good
rule
of
thumb
for
cores
needed:
– Load
Generators:
2N
– Reverse
Proxies:
N
– Web
Servers:
2N
Slide 14
Slide 14 text
COMMON PITFALLS
Slide 15
Slide 15 text
Not Knowing What You Are Testing
• Know
your
tes)ng
tools
• What
ques)on
does
a
test
answer?
– For
example:
• How
many
requests
per
second
can
a
SUT
handle?
• Can
a
SUT
handle
a
certain
number
of
requests
per
second
Slide 16
Slide 16 text
Real Clients versus Synthetic Clients
Real
Clients
Synthe.c
Clients
Latency
Low-‐High
Low
Packet
Loss
Low-‐High
Low
Bandwidth
Low-‐High
High
Time
between
requests
Long
Short
Idle
connec)ons
Yes
No
Slide 17
Slide 17 text
Unrealistic Synthetic Clients
• Misleading
results
– System
looks
good
during
benchmark
– System
has
problems
with
real
clients
• Why
is
this?
– Synthe)c
clients
are
ideal
for
the
server
• Low
latency,
low
packet
loss,
busy
connec)ons
– Real
clients
are
not
• High
latency,
packet
loss,
idle
connec)ons
Slide 18
Slide 18 text
Synthetic Clients
• Unrealis)c
synthe)c
clients
– Apache
Bench
(ab)
• More
realis)c
synthe)c
clients
– Open
Source
• Siege,
wrk
– Commercial
• Spirent,
Ixia,
Cloudtest,
other
cloud
services
Slide 19
Slide 19 text
Misconfiguration
• Many
configura)on
se_ngs
can
impact
tests
– Some
Linux
kernel
se_ngs
may
be
too
low
for
heavy
loads
– Keepalives
– SSL
key
sizes
make
a
big
difference
– Compression
– Benchmark
clients
or
servers
Slide 20
Slide 20 text
Tips and Techniques
• Use
mul)ple
approaches
– Real
world
simula)ons
for
real
world
results
– Simple
tests
for
baselines
and
debugging
Slide 21
Slide 21 text
Tips and Techniques
• If
you
have
found
the
real
limit
of
a
SUT
then:
– At
least
one
system
resource
should
be
exhausted
• CPU
• Memory
• Bandwidth
• Disk
I/O
– If
not,
then
a
bo`leneck
exists
elsewhere
Slide 22
Slide 22 text
Tips and Techniques
• Start
with
the
NGINX
defaults
• NGINX
direc)ves
can
impact
performance
– accept_mutex,
worker_processes,
worker_connec)ons,
keepalive_)meout,
lingering_close,
sendfile,
keepalive,
aio,
open_file_cache
Slide 23
Slide 23 text
Tips and Techniques
• Some
10G
drivers
don’t
use
cores
effec)vely
– Some
cores
at
100%,
others
have
low
usage
– Solu)on:
driver
dependent
• Scrip)ng
• New
driver
version
• New
Card
Slide 24
Slide 24 text
Tips and Techniques
• Monitor
error
files
and
errors
from
tes)ng
tools
– Errors
can
return
faster
– You
may
be
hi_ng
system
limits
or
errors
• Don’t
have
load
genera)on
on
a
SUT
• Double
check
the
result
figures
Slide 25
Slide 25 text
Tips and Techniques
• Run
all
tests
mul)ple
)mes
• If
using
virtualiza)on,
be
aware
of
other
loads
on
the
host
• If
you
don’t
understand
the
results
-‐
simplify
Slide 26
Slide 26 text
Demonstration
Load
Generator
Load
Generator
Apache
NGINX
ab
siege
Datacenter
Slide 27
Slide 27 text
Questions and Answers
Slide 28
Slide 28 text
Closing thoughts
• 38%
of
the
busiest
websites
use
NGINX
• Check
out
the
previous
webinar
on
tuning
at
nginx.com
• Future
webinars:
nginx.com/webinars
Try
NGINX
F/OSS
(nginx.org)
or
NGINX
Plus
(nginx.com)