Your SlideShare is downloading. ×
Ams.rb Oktober
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ams.rb Oktober

546
views

Published on

Presentation given by Menno van der Sman from Wakoopa at Ams.rb

Presentation given by Menno van der Sman from Wakoopa at Ams.rb

Published in: Technology

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
546
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Lessons Learned while building
  • 2. or... How To Run Your Big App on One Server AndAHalf
  • 3. Menno van der Sman Developer at Wakoopa since May 2007
  • 4. Wakoopa is about software
  • 5. PC Mac Linux
  • 6. 200 GB
  • 7. Does it scale?
  • 8. Scaling the front is easy
  • 9. Scaling the back is harder
  • 10. Limits spawn creativity
  • 11. Servers at Railsmachine 16GB RAM 5GB RAM 8 Cores 4 Cores dedicated shared staging archiving production database
  • 12. or... Keeping Your Database Happy
  • 13. Queuing processing multiple items at a time efficient cache update DelayedJob for anything else
  • 14. Smart queries UPDATE developers SET active_seconds = active_seconds + ... INSERT INTO hourly_usage (...) VALUES (...) ON DUPLICATE KEY UPDATE active_seconds = active_seconds + ..., idle_seconds = idle_seconds + ... Allows for concurrency
  • 15. Aim for a Small Rowsize choose a correct datatype pick the right indexes sometimes `id` shouldn’t be the PK
  • 16. composite_primary_keys Allows efficient PK class HourlyUsage < ActiveRecord::Base set_primary_keys :user_id, :software_id, :used_at ... end Original implementation by Dr Nic Maintained by Darrin Holst http://github.com/drnic/composite_primary_keys
  • 17. Archive old data that’s not frequently used SELECT ... FROM hourly_usage WHERE used_at < '...' INTO OUTFILE '/path/to/file' LOAD DATA LOCAL INFILE '/path/to/file' REPLACE INTO TABLE hourly_usage_storage avoids long locks
  • 18. Alternative solution Partitioning 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 ); Makes ‘WHERE software_id = ...’ very fast Didn’t work for us
  • 19. Other Techologies Rails 2.3 Apache Passenger REE 1.8.7 MySQL 5.0 Memcached Sphinx Amazon EC2
  • 20. Our REE settings #!/bin/sh RUBY_HEAP_MIN_SLOTS=500000 RUBY_HEAP_SLOTS_INCREMENT=250000 RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 RUBY_GC_MALLOC_LIMIT=50000000 exec "/opt/ruby-enterprise/bin/ruby" "$@"
  • 21. Questions? or suggestions?

×