webperfdays 2014 - common web performance mistakes

51
Common Web Performance Mistakes Dave Koston, Platform Engineer 1 WebPerfDays 2014

Upload: dkoston

Post on 20-Feb-2017

74 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Webperfdays 2014  - common web performance mistakes

Common Web Performance Mistakes

Dave Koston, Platform Engineer

1

WebPerfDays 2014

Page 2: Webperfdays 2014  - common web performance mistakes

4,000,000,000 packets

2

Page 3: Webperfdays 2014  - common web performance mistakes

3

Page 4: Webperfdays 2014  - common web performance mistakes
Page 5: Webperfdays 2014  - common web performance mistakes

Part 1: Data Interchange

Page 6: Webperfdays 2014  - common web performance mistakes

Part 2: Data Storage and Retrieval

Page 7: Webperfdays 2014  - common web performance mistakes

Part 3: Compute

Page 8: Webperfdays 2014  - common web performance mistakes

Data Interchange Mistake: !

!

Slow Data Formats on Internal Systems

8

Page 9: Webperfdays 2014  - common web performance mistakes

9

Page 10: Webperfdays 2014  - common web performance mistakes

Use faster data formats when you control both sides of the connection

Gain performance on every single request.

10

Page 11: Webperfdays 2014  - common web performance mistakes

Protocol Buffershttps://code.google.com/p/protobuf/

https://github.com/damienbod/SerializationToFileTests11

{"first":"Dave","last":"Koston","phone1":"0123456789","phone2":"1234567890","phone3":"4154447777"}

^F ^DDave 8 ^FKoston"^N !

0123456789^P^B"^N !

1234567890^P^@"^N !

4154447777^P^A

Page 12: Webperfdays 2014  - common web performance mistakes

Serialization TimesJSON vs XML vs BSON vs Protocol Buffers

https://damienbod.wordpress.com/2014/01/09/comparing-protobuf-json-bson-xml-with-net-for-file-streams/12

Page 13: Webperfdays 2014  - common web performance mistakes

De-serialization TimesJSON vs XML vs BSON vs Protocol Buffers

https://damienbod.wordpress.com/2014/01/09/comparing-protobuf-json-bson-xml-with-net-for-file-streams/13

Page 14: Webperfdays 2014  - common web performance mistakes

File SizeJSON vs XML vs BSON vs Protocol Buffers

https://damienbod.wordpress.com/2014/01/09/comparing-protobuf-json-bson-xml-with-net-for-file-streams/14

Page 15: Webperfdays 2014  - common web performance mistakes

Cap’n Proto

http://kentonv.github.io/capnproto/

15

Page 16: Webperfdays 2014  - common web performance mistakes

Cap’n Proto

http://kentonv.github.io/capnproto/

16

Encoding/Decoding Times

0 / 0

Page 17: Webperfdays 2014  - common web performance mistakes

lua-capnproto

http://blog.cloudflare.com/introducing-lua-capnproto-better-serialization-in-lua

17

My webserver doesn’t speak Cap’n Proto!

Page 18: Webperfdays 2014  - common web performance mistakes

Data Storage and Retrieval Mistake: !

One Database To Rule Them All

18

Page 19: Webperfdays 2014  - common web performance mistakes

Cassandra Rules!http://planetcassandra.org/nosql-performance-benchmarks/

Page 20: Webperfdays 2014  - common web performance mistakes

Redis Rules!http://redis.io/topics/benchmarks

Page 21: Webperfdays 2014  - common web performance mistakes

Percona Rules!http://www.percona.com/software/percona-server/benchmarks

Page 22: Webperfdays 2014  - common web performance mistakes

Choose a Database based on your data

AND on how you interact with that data

22

Page 23: Webperfdays 2014  - common web performance mistakes

Use case: User / Product Data

23

Complex Data

“Simple” relationships between data

Relational Database

Percona

MariaDB

PostgreSQL

Page 24: Webperfdays 2014  - common web performance mistakes

Use case: Caching / Configuration Settings

24

Simple data

Lots of reads

Few writes

Key-Value Store

Redis

Kyoto Tycoon

Riak

Page 25: Webperfdays 2014  - common web performance mistakes

Use case: Historical Data

25

Complex, Nested Data

Lots of reads

Few writes

Data stays somewhat constant

Document Store

Couchbase

MongoDB

SimpleDB

ElasticSearch

Page 26: Webperfdays 2014  - common web performance mistakes

Example of 3 Databases in Action

26

http://highscalability.com/blog/2014/1/6/how-hipchat-stores-and-indexes-billions-of-messages-using-el.html

Atlassian HipChat

Key Components:

Authentication

Statistics / Configuration

Message Search and Retrieval

Page 27: Webperfdays 2014  - common web performance mistakes

Authentication

27

http://highscalability.com/blog/2014/1/6/how-hipchat-stores-and-indexes-billions-of-messages-using-el.html

Atlassian HipChat

MariaDB

Understood relationships

Persistent Data

Pros: simple to integrate, persistent, can store complex user objects

Cons: slow, data structure is constant

Page 28: Webperfdays 2014  - common web performance mistakes

Statistics and Configuration Data

28

http://highscalability.com/blog/2014/1/6/how-hipchat-stores-and-indexes-billions-of-messages-using-el.html

Atlassian HipChat

Redis

Variable (but defined) Data

Instant Retrieval

Simple Data Structures

Pros: very fast, caching-oriented design

Cons: limited to simple data (if you want speed), not meant for persistent data

Page 29: Webperfdays 2014  - common web performance mistakes

Statistics and Configuration Data

29

http://highscalability.com/blog/2014/1/6/how-hipchat-stores-and-indexes-billions-of-messages-using-el.html

Atlassian HipChat

ElasticSearch

Variable Data

Lots of reads, and searching

Pros: fast, flexible data, scalable!

Cons: limited to simple data (if you want speed)

Page 30: Webperfdays 2014  - common web performance mistakes

!

How do I know which is best?

30

Page 31: Webperfdays 2014  - common web performance mistakes

!

Use benchmarking tools, not benchmark results

31

Page 32: Webperfdays 2014  - common web performance mistakes

JMeterhttp://jmeter.apache.org/index.html

Test your web app, any database you have a java driver for32

Page 33: Webperfdays 2014  - common web performance mistakes

JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html

33

Page 34: Webperfdays 2014  - common web performance mistakes

JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html

34

Page 35: Webperfdays 2014  - common web performance mistakes

JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html

35

Page 36: Webperfdays 2014  - common web performance mistakes

JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html

36

Page 37: Webperfdays 2014  - common web performance mistakes

JMeter for HTTP Testinghttp://jmeter.apache.org/usermanual/build-web-test-plan.html

37

Page 38: Webperfdays 2014  - common web performance mistakes

Add JMeter to Continuous Integrationhttp://www.programmerplanet.org/projects/jmeter-ant-task/

38

Page 39: Webperfdays 2014  - common web performance mistakes

Add JMeter to Jenkinshttps://wiki.jenkins-ci.org/display/JENKINS/Integrating+TestLink++Jenkins++JMeter

39

Page 40: Webperfdays 2014  - common web performance mistakes

Add JMeter to Bamboohttps://marketplace.atlassian.com/plugins/jmeterAggregator

40

Page 41: Webperfdays 2014  - common web performance mistakes

Freebie Mistake: !

Not using your Database for Compute

41

Page 42: Webperfdays 2014  - common web performance mistakes

Database ComputeMap-Reduce

Stored Procedures

42

Page 43: Webperfdays 2014  - common web performance mistakes

Compute Mistake: !

Language Dogma

43

Page 44: Webperfdays 2014  - common web performance mistakes

http://www.techempower.com/benchmarks

44

Netty Rules!

Page 45: Webperfdays 2014  - common web performance mistakes

http://www.techempower.com/benchmarks

45

Gemini Rules!

Page 46: Webperfdays 2014  - common web performance mistakes

http://www.techempower.com/benchmarks

46

Start Rules! Wait…wtf is Start?

Page 47: Webperfdays 2014  - common web performance mistakes

Bash C C++ C# Go JavaScript

Lua Perl PHP Python !

https://github.com/cloudflare

47

Page 48: Webperfdays 2014  - common web performance mistakes

Language Diversity Benefits

• Forced separation of service layers

• Recruit from a broader range of people

• Hiring of polyglot programmers

• Easily find multiple ways to solve problems

48

Page 49: Webperfdays 2014  - common web performance mistakes

Our toolbox in our minds

http://www.freedigitalphotos.net/

Page 50: Webperfdays 2014  - common web performance mistakes

Our toolbox in reality

http://www.freedigitalphotos.net/

Page 51: Webperfdays 2014  - common web performance mistakes

Q & A

@davekoston [email protected]

51