77
“Startup DevOps” Tuesday, 12th August 2014 Jon Milsom Cofounder & CTO

Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Embed Size (px)

DESCRIPTION

Presentation at Leeds DevOps by Jon Milsom (Co-Founder & CTO, Pitchero), August 2014 http://www.pitchero.com/ http://www.leedsdevops.org.uk/ https://twitter.com/jonmilsom https://twitter.com/leedsDevops

Citation preview

Page 1: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

“Startup  DevOps”  Tuesday,  12th  August  2014  

Jon  Milsom  Co-­‐founder  &  CTO  

 

Page 2: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Hiring  

•  Roles  – FullHme  Junior  Dev  (Frontend  &  some  PHP)  – Freelance  SysAdmins  /  Ops  for  ad-­‐hoc  projects  

•  Opportunity  – Make  a  big  impact  in  a  small  team  

Page 3: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

WHAT  IS  PITCHERO?  

Page 4: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Websites  for  amateur  sports  teams  

Page 5: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Online  management  plaRorm  for  amateur  sports  teams/clubs/leagues/counHes/governing  

bodies  

Page 6: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Market?  

Page 7: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Not  this…  

Page 8: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Source:  hWp://images.football365.com/13/03/800x600/David-­‐Beckham-­‐St-­‐EHenne-­‐v-­‐PSG-­‐2013_2917145.jpg  

Page 9: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

This…  

Page 10: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Source:  hWp://sanford-­‐soccer-­‐net.blogspot.co.uk/2011/03/massive-­‐aWack-­‐loving-­‐tribute-­‐to-­‐fat.html  

Page 11: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Traffic  

Page 12: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 13: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

iPhone  

Jan  2013  

Page 14: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

User  generated  content  

Page 15: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Tech  Team  

Page 16: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

THE  “HYBRID”  CLOUD  

Page 17: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Hybrid  Cloud?  

Image  from:  hWp://www.rackspace.com/cloud/hybrid/  

Page 18: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Why  Hybrid?  

•  Reliable  (keep  some  dedicated  boxes)  •  Easy  to  scale  

Page 19: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Moving  from  dedicated  boxes…  

•  Moved  session  management  into  Redis  •  Don’t  rely  on  file  system  •  Don’t  rely  on  any  single  node  •  Rely  on  config  files  •  Yada  yada…  Loads  of  other  stuff  that  I  can’t  recall  

Page 20: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Cool!  

Source:  hWp://www.ktvu.com/news/entertainment/funk-­‐legend-­‐headlines-­‐sf/nD63D/  

Page 21: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Not  cool  L  

Source:  hWp://www.mixcrate.com/oneworld/phenoms-­‐of-­‐funk-­‐george-­‐clintonparliamenRunkadelicbootsy-­‐collins-­‐162038  

Page 22: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

In  pracHce  

Previously  internal  traffic  now  goes  through  firewall  &  back  out  

Page 23: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Issues  -­‐  Latency  

Page 24: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Issues  -­‐  Latency  

Approx  40ms  memcache.  ~  20%  of  total!  

Page 25: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Issues  -­‐  Throughput  

Page 26: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Issues  -­‐  Throughput  

•  Exceeded  internal  throughput  –  Increased  latency  – Dropped  packets  

•  Had  to  upgrade  firewall  – UnanHcipated  cost  

Page 27: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

MESSAGE  QUEUES  

Page 28: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

NewsleWer  System  

•  1M  emails  /  month  •  Up  to  200k/day  •  Generated  dynamically  

Page 29: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

NewsleWer  System  

•  Via  Cron  – Synchronous  process  – Sent  via  5  minute  cron  – 500  in  a  batch  

Page 30: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Problem?  

Page 31: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

144,000  emails  per  day  

Page 32: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

200,000  subscripHons  

Page 33: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

200,000  >  144,000  

Page 34: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 35: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon…  

High-­‐Scale  Async  Processing  

The  Message  Queue  For  the  Cloud  

Page 36: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 37: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

NewsleWer  System  

•  Via  MQ  – Processed  Async  – Sent  quickly  

•  200k+  within  1  hour  – X  concurrent  workers  

Page 38: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

NewsleWer  System  

•  Sessions  •  Average  peak  before:  5,000  •  Average  peak  aver:  10,000  

“Business”  results…  

Page 39: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

CACHING  

Page 40: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Simple  Model  

Page 41: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

OpHmal  Caching  

•  Every  client  wants  the  same  content  •  The  content  doesn’t  change  oven  

Page 42: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

OpHmal  Caching  

•  Every  client  wants  the  same  content  •  The  content  doesn’t  change  oven  

Page 43: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Pitchero  Model  

Page 44: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 45: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

OpHon  #1  –  Increase  DB  layer  

•  Pros  – Simplify  development  

 •  Cons  – OperaHons  headache  – Expensive  – Performance  hit  

Page 46: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

OpHon  #2  –  Intelligent  caching  

•  Pros  – Cheap  (spare  RAM?)  – Fast  – Low  operaHons  overhead  

•  Cons  – Dev  work  – Not  relaHonal  – Can’t  rely  on  a  key  exisHng  

Page 47: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

“There  are  only  two  hard  things  in  Computer  Science:  cache  invalida:on  and  naming  things.“    -­‐  Phil  Karlton  

Page 48: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

“There  are  only  two  hard  things  in  Computer  Science:  cache  invalida:on  and  naming  things.“    -­‐  Phil  Karlton  

Page 49: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

ProperHes  of  our  plaRorm  

•  Natural  Groups  – PlaRorms  

•  Club  •  League  •  County  

Page 50: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

ProperHes  of  our  plaRorm  

•  Natural  Groups  – PlaRorms  

•  Club  –  Discreet  club_ids:  x,y,z  

•  League  –  Discreet  league_ids:  i,j,k  

•  County  –  Discreet  county_ids:  p,q,r  

Page 51: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #1  “The  InvalidaHon  Manager”  

•  ApplicaHon  – “I  have  changed  A”  

•  InvalidaHon  Manager  – “I  will  invalidate  A1,  A2,  A3”  

Page 52: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Feeling  preWy  smug…  

Source:  hWp://www.showbiz411.com/tag/ricky-­‐gervais  

Page 53: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

What  really  happened…  

•  ApplicaHon  –  “I  have  changed  A”  

•  InvalidaHon  Manager  –  “I  will  invalidate  A1,  A2,  A3,  B2,  C7,  D4,  F8,  G8,  A3  (twice!),  B6,  H28,  M14,  J139”  

Page 54: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

“The  InvalidaHon  Manager”  Un-­‐managable!  

Page 55: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Problems  

•  Cross  domain  dependencies  A,  B,  C  etc  •  Reliance  on  developers  •  Large  number  of  invalidaHon  events  •  Users  content  disappeared  •  Users  could  not  delete  content  

Page 56: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  Example  cache  keys  – “club1234_news56789”  – “club1234_report4321”  – “club1234_video1357”  

Page 57: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  Example  cache  keys  – “club1234_news56789”  – “club1234_report4321”  – “club1234_video1357”  

Page 58: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  Example  cache  keys  – “{club}_news56789”  – “{club}_report4321”  – “{club}_video1357”  

•  {club}  is  a  variable,  stored  in  memcache  •  {club}  =  hash_fn(club,  club_id,  Hme())  

Page 59: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Just  added  support  for  dynamically  namespacing  memcache  keys…  

Source:  hWp://www.troll.me/meme/fist-­‐baby  

Page 60: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  EffecHvely  namespaced  cache  keys  •  Can  now  invalidate*  an  enHre  plaRorms  (e.g.  club_id:1234)  data  in  one  command  

•  No  required  knowledge  of  the  rest  of  the  key  •  Don’t  need  to  add  keys  to  invalidaHon  manager  each  Hme  we  add  new  funcHonality  

*No  actual  invalidaHon  happens:  we  just  change  the  names  of  the  keys  to  something  that  doesn’t  exist.  Memcache  will  garbage  collect  based  on  LRU.  

Page 61: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  Results  – Reduced  load  on  database  – Low  ops  overhead  – LiWle  input  required  from  developers  

Page 62: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

SoluHon  #2  –  “PlaRorm  Cache”  

•  Not  perfect  – Requires  an  extra  memcache  lookup  for  the  namespace  key  

Page 63: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

ON-­‐DEMAND  IMAGE  PROCESSING  

Page 64: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 65: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 66: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014
Page 67: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Any  image  

Page 68: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Any  size  

Page 69: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

As  the  page  loads  

Page 70: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Problems  

•  10M  images  •  Currently  in  3  sizes  (30M  objects)  •  Up  to  50  images  on  some  pages  – High  traffic  =>  very  high  request  rate  

 

Page 71: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

Old  Model  

3  set  sizes    /{user_id}/{image_id}.jpg  -­‐  600x450    /{user_id}/sm_{image_id}.jpg  -­‐  120x90    /{user_id}/Hny_{image_id}.jpg  -­‐  50x37  

Page 72: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

New  Model  

Any  image,  any  size    /?url={s3_image_url}&w={width}&h={height}&q={quality}    Hash  parameters  and  store  on  disk  once  generated        Checkout:  hWp://images.weserv.nl/  

Page 73: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

New  Model  

Super  fast…    Average  server  response  15ms  (CloudFront  faster?)    >>  CloudFront  

   >>  Server  (from  disk)          >>  Server  (generate  from  S3  original)  

Page 74: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

WHAT  ABOUT  “DEVOPS”?  

Page 75: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

DevOps  Status  

•  Dev  working  pracHces  – Version  control  – One  command  deployment  –  (Some)  automated  tesHng  

•  Ops  working  pracHces  in  infancy  – Setup  lists  &  bash  scripts  – Not  taking  advantage  of  the  cloud  

Page 76: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

The  Future  

•  Infrastructure  as  code  •  More  automated  tesHng  •  BeWer  automated  tesHng  •  Cloud?  Dedicated?  

Page 77: Startup DevOps - Jon Milsom Pitchero - Leeds DevOps - August 2014

QuesHons?  

@jonmilsom  [email protected]  

hWp://uk.linkedin.com/in/jonmilsom