pycon au 2015 - using benchmarks to understand how wsgi servers work

33
Using benchmarks to understand how WSGI servers work Graham Dumpleton PyCon AU - August 2015 targeted testing

Upload: graham-dumpleton

Post on 16-Apr-2017

487 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Using benchmarks to understand how WSGI

servers work

Graham Dumpleton PyCon AU - August 2015

targeted testing

Page 2: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

http://www.modwsgi.org

Page 3: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Lies, damned lies and benchmarks

http://nichol.as/benchmark-of-python-web-servers

https://en.wikipedia.org/wiki/Tornado_(web_server)

http://www.fapws.org/benchmarks

Page 4: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

The real goal

• Configuring your WSGI server.

• Number of processes.

• Number of threads per process.

• When to scale out to more hosts.

Page 5: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Visualising traffic

Page 6: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Visualising traffic

Page 7: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Concurrent requests

Page 8: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Concurrent requests

3

2

1

Processes

Page 9: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Concurrent requests

3

2

1

Processes Threads

1

2

3

Page 10: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Capacity utilisation

3

2

1

Processes Threads

1

2

3

Page 11: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU burn (request)

Page 12: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

I/O Bound - 1 Client

Page 13: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

I/O Bound - 4 Clients

Page 14: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU Bound - 1 Client

Page 15: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU Bound - 2 Clients

Page 16: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU Bound - 4 Clients (1)

4

1

2

Page 17: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU burn calculation

CPU usage CPU burn = ————

request time

CPU usage = user CPU time + system CPU time

Page 18: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Increasing concurrency

0%

25%

50%

75%

100%

0 secs

3 secs

6 secs

9 secs

12 secs

1 2 3 4 5 6 7 8 9 10

Request time CPU time (request) CPU burn (request)

Concurrent requests

Page 19: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU burn (process)

Page 20: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

CPU Bound - 4 Clients (2)

4

1

2

Page 21: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

100% CPU burn

0%

40%

80%

120%

160%

0 secs

3 secs

6 secs

9 secs

12 secs

1 2 3 4 5 6 7 8 9 10

Request time CPU time (request) CPU burn (request)CPU burn (process)

Concurrent requests

Page 22: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

25% CPU burn

0%

40%

80%

120%

160%

0 secs

0.75 secs

1.5 secs

2.25 secs

3 secs

1 2 3 4 5 6 7 8 9 10

Request time CPU time (request) CPU burn (request)CPU burn (process)

Concurrent requests

Page 23: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Global interpreter lock

Page 24: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Poor mans threading

Waiting for I/O (thread is blocked)

Running (thread active)

Waiting for GIL

Thread 1

Thread 2

Page 25: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

100% CPU burn4 Processes / 1 Thread

0%

40%

80%

120%

160%

0 secs

0.25 secs

0.5 secs

0.75 secs

1 secs

1 2 3 4 5 6 7 8 9 10

Request time CPU time (request) CPU burn (request)CPU burn (process)

Concurrent requests

Page 26: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

100% CPU burn + Queue time4 Processes / 1 Thread

0%

40%

80%

120%

160%

0 secs

0.5 secs

1 secs

1.5 secs

2 secs

1 2 3 4 5 6 7 8 9 10

Request time CPU time (request) CPU burn (request)CPU burn (process) Queue time (max)

Concurrent requests

Page 27: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Reaching capacity4 Clients ==> 4 Processes / 1 Thread

1

1

1

1

2

2

2

2

3

3

3

3

4

4

4

4

Page 28: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

5 clients ==> 4 Processes / 1 Thread

Capacity reached

Delayed

1

1

1

1

1

2

2

2

2

2

3

3

3

3

3 4

Page 29: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

All requests are not the same

Page 30: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Don’t trust benchmarks

Page 31: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Is there an answer?

Page 32: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Where to next?

• Performance monitoring integral to mod_wsgi.

• A detailed blog series to followup this talk.

Page 33: PyCon AU 2015  - Using benchmarks to understand how wsgi servers work

Contact [email protected]

@GrahamDumpleton

http://blog.dscpl.com.au

http://blog.openshift.com