130 likes | 234 Views
Scaling Rails (or other web frameworks). Fact or Fiction?. Is a RDMS necessary?. No? Then NoSQL Google Bigtable Apache Casandra Amazon Dynamo Couch DB Mongo DB. Is a RDMS necessary?. Yes Mysql Ourdelta Percona XtraDB MariaDB Drizzle Postgres. Optimize first, Cache later.
E N D
Scaling Rails(or other web frameworks) Fact or Fiction?
Is a RDMS necessary? • No? Then NoSQL • Google Bigtable • Apache Casandra • Amazon Dynamo • Couch DB • Mongo DB
Is a RDMS necessary? • Yes • Mysql • Ourdelta • PerconaXtraDB • MariaDB • Drizzle • Postgres
Optimize first, Cache later • “There are only two hard things in Computer Science: cache invalidation and naming things” Phil Karlton • If you cache first, then you have no where to go when you are on Slashdot, Glen Beck, or any other high traffic time • Benchmark to know where to improve and to see changes. • Shard logically then by hash
Optimize first, Cache later • Start with low hanging fruit – • use code profiling gems/plugins • Slowquerylog • mk-query-digest • Index everything • Remove unused indices • Preconaoption to add queries without an index in slow query log • Don’t use N+1 queries • Avoid temporary disk tables,
PerconaMysql Percona 5.1 is faster than Mysql 5.5 Patches from Google, Facebook, and many more More options for optimizing, logging, and profiling Hot backups without buying expensive utilities Stable performance
Performance Tips for MYSQL If possible enough ram for all data, if possible SSD If not, as much ram a possible + SLC SSD R/W latency Temporary Tables use MYISAM cache options Allocate enough ram for temp memory tables Put temporary disk tables on ram disk or SSD Querycache can help or hinder Avoid RAND() if possible – horrible scaling Don’t use a DB for analytics, that’s what logs are for
Nginx, Passenger, REE REE As fast if not faster than ruby 1.92 Passenger + REE = Memory Savings No babysiting mongrels, thins, etc Garbage Collection tuning Nginx + Passenger = ROR + static file serving without the bloat of apache + passenger
Don’t Use MYSQL for fulltext searches DataparkSearch Ferret Ht-//Dig Hyper Estraier Lemur/Indri Lucene mnoGoSearch Sphinx Swish-e Xapian
Where to cache • SQL: • DB server • Memcached • Rails • Rails: • Active Record, • Actions, • Partials, • page • Reverse Proxy • Object and ESI
Reverse Caching Proxy Squid Pound Apache httpd Apache TS Lighttpd Nginx Varnish
Varnish Extremely High Performance Doesn’t fight OS’s VMM Multiple storage options Saint Mode Edge Side Includes Extremely threaded Inline C Backend health checking Load balancing
Page Load Times • Search Engines take it into account in ranking • Combined, Minify, compress, CSS and JS • Compress html • Use CSS sprites • Set expires tags • Crush images • Multiple static servers, • Divide total #of static items by 4 for optimal # of servers • Benchmark with Google Pagespeed, Yahoo Yslow, firebug.