lessons learned at wakoopa

28

Upload: menno-van-der-sman

Post on 05-Nov-2014

2.207 views

Category:

Technology


4 download

DESCRIPTION

The talk I gave at RubyEnRails 2008

TRANSCRIPT

Page 1: Lessons Learned at Wakoopa
Page 2: Lessons Learned at Wakoopa

Lessons Learnedwhile building Wakoopa

Page 3: Lessons Learned at Wakoopa

Menno van der SmanDeveloper at Wakoopa

since May 2007

Page 4: Lessons Learned at Wakoopa

Wakoopa is about software

Page 5: Lessons Learned at Wakoopa
Page 6: Lessons Learned at Wakoopa

MacPC

Page 7: Lessons Learned at Wakoopa

200million

Page 8: Lessons Learned at Wakoopa

Does it scale?

Page 9: Lessons Learned at Wakoopa

Scaling the front is easy

Page 10: Lessons Learned at Wakoopa

Scaling the back is harder

Page 11: Lessons Learned at Wakoopa

Limits spawn creativity

Page 12: Lessons Learned at Wakoopa

One server

at Railsmachinesliced into staging, production and db

MySQL 4.1Apache + Mongrel

Page 13: Lessons Learned at Wakoopa

Background queue

Page 14: Lessons Learned at Wakoopa

Lots of tools already

BackgroundRB, DelayedJob, Daemons etc

Page 15: Lessons Learned at Wakoopa

Rolling our own

database basedusing script/runner

processing multiple items in one loopone cache update per loop

Page 16: Lessons Learned at Wakoopa

Smart queries

INSERT INTO hourly_usage (...) VALUES (...) ON DUPLICATE KEY UPDATE active_seconds = active_seconds + ..., idle_seconds = idle_seconds + ...

UPDATE developers SET active_seconds = active_seconds + ...

Allows for concurrency

Page 17: Lessons Learned at Wakoopa

Size = rowsize x rows

Make rowsize smaller

Page 18: Lessons Learned at Wakoopa

sometimes `id` shouldn’t be the

Primary Key

Page 19: Lessons Learned at Wakoopa

Enter composite_primary_keys

Page 20: Lessons Learned at Wakoopa

Overrides default PK

Original idea by Dr NicEnhanced for Rail 2.1 by Darrin Holsthttp://compositekeys.rubyforge.org/

class HourlyUsage < ActiveRecord::Base set_primary_keys :user_id, :software_id, :used_at ...end

Page 21: Lessons Learned at Wakoopa

Archive old datathat’s not frequently used

Page 22: Lessons Learned at Wakoopa

HourlyUsageto

HourlyUsageStorage

SELECT ... FROM hourly_usage WHERE used_at < '...' INTO OUTFILE '/path/to/file'

LOAD DATA INFILE '/path/to/file' REPLACE INTO TABLE hourly_usage_storage

avoids long locks

Page 23: Lessons Learned at Wakoopa

Upcoming improvements

Page 24: Lessons Learned at Wakoopa

MySQL 5.1Partitioning

CREATE TABLE hourly_usage_storage ( ... )PARTITION BY RANGE (software_id) ( PARTITION p0 VALUES LESS THAN (...), PARTITION p1 VALUES LESS THAN (...), PARTITION p2 VALUES LESS THAN (...), PARTITION p3 VALUES LESS THAN (...), .... PARTITION pn VALUES LESS THAN MAXVALUE);

Available in MySQL 5.1

Makes ‘WHERE software_id = ...’ very fast

Page 25: Lessons Learned at Wakoopa

And many more plans

MySQL 5.1Memcached

SphinxRails 2.1

Amazon EC2

Designing a new infrastructure

Page 26: Lessons Learned at Wakoopa

Announcing a new blog

Inside Wakoopahttp://inside.wakoopa.com

Page 27: Lessons Learned at Wakoopa

Questions?

http://wakoopa.com/jobs

Looking for C++ and frontend awesomeness

or suggestions?

Page 28: Lessons Learned at Wakoopa