webperfdays 2014 - common web performance mistakes
TRANSCRIPT
Common Web Performance Mistakes
Dave Koston, Platform Engineer
1
WebPerfDays 2014
4,000,000,000 packets
2
3
Part 1: Data Interchange
Part 2: Data Storage and Retrieval
Part 3: Compute
Data Interchange Mistake: !
!
Slow Data Formats on Internal Systems
8
9
Use faster data formats when you control both sides of the connection
Gain performance on every single request.
10
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
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
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
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
Cap’n Proto
http://kentonv.github.io/capnproto/
16
Encoding/Decoding Times
0 / 0
lua-capnproto
http://blog.cloudflare.com/introducing-lua-capnproto-better-serialization-in-lua
17
My webserver doesn’t speak Cap’n Proto!
Data Storage and Retrieval Mistake: !
One Database To Rule Them All
18
Cassandra Rules!http://planetcassandra.org/nosql-performance-benchmarks/
Redis Rules!http://redis.io/topics/benchmarks
Percona Rules!http://www.percona.com/software/percona-server/benchmarks
Choose a Database based on your data
AND on how you interact with that data
22
Use case: User / Product Data
23
Complex Data
“Simple” relationships between data
Relational Database
Percona
MariaDB
PostgreSQL
Use case: Caching / Configuration Settings
24
Simple data
Lots of reads
Few writes
Key-Value Store
Redis
Kyoto Tycoon
Riak
Use case: Historical Data
25
Complex, Nested Data
Lots of reads
Few writes
Data stays somewhat constant
Document Store
Couchbase
MongoDB
SimpleDB
ElasticSearch
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
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
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
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)
!
How do I know which is best?
30
!
Use benchmarking tools, not benchmark results
31
JMeterhttp://jmeter.apache.org/index.html
Test your web app, any database you have a java driver for32
JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html
33
JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html
34
JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html
35
JMeter for Database Testinghttp://jmeter.apache.org/usermanual/build-db-test-plan.html
36
JMeter for HTTP Testinghttp://jmeter.apache.org/usermanual/build-web-test-plan.html
37
Add JMeter to Continuous Integrationhttp://www.programmerplanet.org/projects/jmeter-ant-task/
38
Add JMeter to Jenkinshttps://wiki.jenkins-ci.org/display/JENKINS/Integrating+TestLink++Jenkins++JMeter
39
Add JMeter to Bamboohttps://marketplace.atlassian.com/plugins/jmeterAggregator
40
Freebie Mistake: !
Not using your Database for Compute
41
Database ComputeMap-Reduce
Stored Procedures
42
Compute Mistake: !
Language Dogma
43
http://www.techempower.com/benchmarks
46
Start Rules! Wait…wtf is Start?
Bash C C++ C# Go JavaScript
Lua Perl PHP Python !
https://github.com/cloudflare
47
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