Speeding up Page Load Times by Using Starling

4,452 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,452
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Speeding up Page Load Times by Using Starling

  1. 1. Faster Response TimesBy using the Starling Queue Server Erik Osterman Launch 10 Labs LLC http://launch10.com
  2. 2. What is the problem?● You want to write a lot of data quickly ○ e.g. tons of INSERTs & UPDATEs ○ Bursts exceed capacity ○ No ability to throttle requests● Requests that modify stored data are slow / timeout ○ Reduced page impressions ○ Reduced revenues (CPM) ○ Customers bail ○ You look bad!● Added Memcache, but its still slow (duh?)! ○ Memcache only speeds up reads, not writes
  3. 3. What is the solution?● Dont write to the database!● Create jobs in the queue instead of writes to the DB● Writing objects to queue is FAST● Use a multi-threaded batch processor to run the jobs "As fast as you can"● Jargon (queue, job, batch processor)
  4. 4. Why use Starling?● Used in massive production environments● Lightweight, Extremely FAST● Persistent (crash recoverable)● Trivial to scale; scales just like memcached● Handles hundreds of thousands of items● Thousands of queue inserts per second● Speaks Memcache protocol (very simple! very portable!)● Minimal code changes*● Named Queues● Performance metrics / stats● GNU LGPL License (= Free software!)● (Not Java)
  5. 5. Everyones doing it.....● The Dot Game & Paradigm (starling)● Twitter (starling)● Friends For Sale (starling)● FiveRuns (starling)● Causes on Facebook (beanstalkd)● ShareThis (SQS)● Alexa (SQS)● Insert your company here Maybe you should too!
  6. 6. What do I need to use Starling?Not much! ● Server with Ruby to run Starling ● # gem install starling ● Memcache Client ● Configure application to add jobs to the queue ● Batch process to run the jobs in the queue
  7. 7. PHP Example (request)// index.php<?php$memcache = new Memcache();$memcache->addServer(localhost, 22122);$memcache->set(last_seen, Array(user_id=> $_SESSION[user_id],timestamp => time()));?>
  8. 8. PHP Example (batch)<?php// process-jobs.php$memcache = new Memcache();$memcache->addServer(localhost, 22122);while(true){ if($job = $memcache->get(last_seen)) { // Process $job } else { // Queue empty! sleep(1); }}?>
  9. 9. What are my alternatives?● Increase I/O capacity (expensive!)● Use a faster DB solution● Shard your database (hard!)● Master-master replication (tricky!)● Memcache (Wrong answer! not applicable)● Use a simple queue table (slow!)● Optimize tables / reduce FKs & indexes / change engine● Write less Best solution? As many optimizations as you can.
  10. 10. Other Queue Servers ● Starling (LGPL) ● BeanStalk (GNU GPL v3) ● Open Message Queue(CDDL / GPL v2) ● Apache Active MQ (Apache 2.0 License) ● Rabbit MQ (Mozilla Public License) ● Sparrow (MIT License) ● Scarling (ISC license) ● MySQL Home brewed solutionNot so free ● Amazon SQS (Pay per Query) ● Microsoft Message Queue Server ● IBM WebSphere MQ
  11. 11. Q&A What did I miss?tinyurl.com/L10-starling Erik Osterman www.launch10.com eosterman@launch10.com

×