building a platform from open source

128
Building a pla+orm from open source Dustin Whittle

Upload: dustin-whittle

Post on 09-May-2015

2.566 views

Category:

Technology


2 download

DESCRIPTION

Building a platform from open source

TRANSCRIPT

Page 1: Building a platform from open source

Building  a  pla+orm  from  open  source  

Dustin Whittle

Page 2: Building a platform from open source

Building  a  pla+orm  from  open  source  

Page 3: Building a platform from open source

Who  am  I?    •  A  hacker  on  the  web  for  the  last  decade  •  Worked  with  symfony  since  open  source  •  Developed  ysymfony  at  Yahoo!  •  Consultant  helping  startups  scale  web  apps  

•  A  speaker  at  conferences  around  the  world  

   

[email protected]    @dusBnwhiDle  

hDp://dusBnwhiDle.com/    

Page 4: Building a platform from open source

When  I  started  developing…  

Page 5: Building a platform from open source

It  was  really  simple  

Page 6: Building a platform from open source

1  shared  host  /  simple  PHP  scripts  

Page 7: Building a platform from open source

Then  I  started  working  on  lots  of  consulBng  projects  

Page 8: Building a platform from open source

I  realized  I  needed  a  beDer  set  of  tools  

Page 9: Building a platform from open source

I  started  exploring  web  frameworks  

Page 10: Building a platform from open source
Page 11: Building a platform from open source

I realized reading and using other peoples code made me a

better, more productive developer

Page 12: Building a platform from open source

I started talking about how frameworks like symfony and

YUI improve quality and productivity at conferences

Page 13: Building a platform from open source

Then I went to work at Yahoo to help build a frontend platform

based on an open source framework

Page 14: Building a platform from open source

I realized web application stacks are very similar

Lots of the same problems and

solutions

Page 15: Building a platform from open source

Users  

Load  Balancers  

Frontend  

PHP  APC,  PEAR,  PECL  

Linux  

 symfony  /  YUI  

 

Apache  Custom  Modules  

Backend  

MySQL/Memcache   Web  Services  /  YQL   Ad  API   User  API  

Page 16: Building a platform from open source

Why  a  frontend  pla+orm?  

Build  applicaBons  to  requirements    Do  exactly  what  you  need:  no  more,  no  less  

 Choose  open  source  or  build  your  own  

Everyone  uses  a  framework  If  you  use  open  source,  support/maintenance  is  free  

Understand  that  frameworks  add  a  lot  of  overhead  (features  have  a  cost)  

Page 17: Building a platform from open source

Needs  from  a  frontend  pla+orm  Fit  server  environments  (Linux/PHP5/Apache)  Development  Cycle  –  How  easy  to  develop,  test,  and  deploy?  

Clean  separaBon  between  data,  logic,  and  display  Independent  model  layer  to  fit  service  oriented  architecture  

Extensible  and  pluggable  InternaBonalizaBon  and  localizaBon  support  Detailed  documentaBon  and  acBve  community  of  support  

Open  source  and  ability  to  contribute  back  

Page 18: Building a platform from open source

Why  a  framework  at  all?  Another  so]ware  layer  (ysymfony,  yphp,  yapache)  

Factors  out  common  paDerns  Code  Layout  ConfiguraBon  URL  RouBng  AuthenBcaBon  /  Security  Form  ValidaBon  /  RepopulaBon  InternaBonalizaBon  /  LocalizaBon  

Encourages  good  design  AbstracBon  >  Consistency  >  Maintainability    

Page 19: Building a platform from open source
Page 20: Building a platform from open source
Page 21: Building a platform from open source

The  choice  to  adopt  symfony?  Philosophy  

Full-­‐stack  framework  for  building  complex  web  applicaBons  

Adopt  best  ideas  from  anywhere,  using  exisBng  code  if  available  (Mojavi,  Prado,  Rails,  Django)  

 Design  Clean  separaBon  between  Model,  View,  and  Controller  

Controller  using  modules  and  acBons  Views  using  templates  in  straight  PHP  with  helpers  Easy  to  reuse  view  modules  to  compose  a  page  

Layouts,  Components,  ParBals,  Slots  

Page 22: Building a platform from open source

The  choice  to  use  symfony  

Configurability  /  Flexibility  Features  we  do  not  want  are  easily  disabled  Use  of  factories  for  easy  customizaBon  

DocumentaBon  /  Support  Community  The  DefiniBve  Guide  to  symfony  Askeet,  Jobeet,  Cookbooks,  Advents  

AcBve  community  with  wiki,  mailing  lists,  forums,  irc  channel  

 

Page 23: Building a platform from open source
Page 24: Building a platform from open source
Page 25: Building a platform from open source
Page 26: Building a platform from open source
Page 27: Building a platform from open source
Page 28: Building a platform from open source

A  look  at  Yahoo!  Answers  

hDp://answers.yahoo.com  Yahoo!  Answers  is  the  largest  collecBon  of  human  knowledge  on  the  Web  with  more  than  135  million  users  and  515  million  answers  worldwide  (Yahoo!  Internal  Data,  March  2008).  

Yahoo!  Answers  is  the  2nd  ranked  educaBon  &  reference  site  on  the  web  (comScore)  

Available  in  26  markets  and  12  languages  

Page 29: Building a platform from open source

Yahoo!  Answers  at  the  beginning  

Started  as  a  small  development  team  on  PHP4  from  a  fork  of  Yahoo!  Taiwan  Knowledge+  

Launched  December  2005  by  December  2006  there  were  60  million  users  and  65  million  answers  

The  code  base  eventually  became  difficult  to  maintain  and  iterate  new  features  

Large  distributed  development  teams  

Page 30: Building a platform from open source
Page 31: Building a platform from open source
Page 32: Building a platform from open source
Page 33: Building a platform from open source
Page 34: Building a platform from open source
Page 35: Building a platform from open source
Page 36: Building a platform from open source

JavaScript  Framework  UBliBes  -­‐  YAHOO,  Dom,  Event,  AnimaBon,  Browser  History  Manager,  ConnecBon  Manager,  Cookie,  DataSource,  Drag  and  Drop,  Element,  Get,  ImageLoader,  JSON,  Resize,  Selector,  Loader  

Controls  /  Widgets  -­‐  AutoComplete,  BuDon,  Calendar,  Charts,  Color  Picker,  DataTable,  ImageCropper,  Rich  Text  Editor,  Slider,  Uploader  

Container  (Module,  Overlay,  Panel,  ToolBp,  Dialog),  Layout  Manager,  Menu,  TabView,  TreeView  

Debug  –  Logger,  Profiler,  Test  

Y!  Developer  Network  –  YUI  Javascript  

Page 37: Building a platform from open source

CSS  FoundaBon  Reset  -­‐  Neutralizes  browser  CSS  styles  Base  -­‐  Applies  consistent  style  foundaBon  Fonts  -­‐  FoundaBon  for  typography  and  font-­‐sizing  Grids  -­‐  Thousands  of  wireframe  layouts  

User  Interface  Design  PaDerns  Library  Proven  soluBons  to  common  interfaces  hDp://developer.yahoo.com/ypaDerns/  Grade  Browser  Support  /  Progressive  Enhancement  

Y!  Developer  Network  –  YUI  CSS  

Page 38: Building a platform from open source

More  than  275  funcBonal  examples  hDp://developer.yahoo.com/yui/examples/  

YSlow  +  Performance  Rules  hDp://developer.yahoo.com/performance  

YUI  Blog  hDp://yuiblog.com/  

Mailing  List  @  Yahoo!  Groups  hDp://tech.groups.yahoo.com/group/ydn-­‐javascript/  

 

Y!  Developer  Network  –  DocumentaBon  

Page 39: Building a platform from open source

The  big  picture  

A  complete  pla+orm  for  building  web  applicaBons  from  frameworks  PHP  Framework  JavaScript  Framework  CSS  Framework  UI  Design  PaDerns  +  Best  PracBces  Development  Tools  (logger,  profiler,  debugger,  docs)  

Unit  +  FuncBonal  TesBng  Frameworks  (LIME  /  YUI  Test)  

Deployment  Tools  

Page 40: Building a platform from open source

What  does  Yahoo!  change?  Minor  changes  to  fit  our  environment  

Most  changes  are  easily  implemented  via  factories/plugins    Dropped  the  ORM  and  pushed  down  the  stack  (SOA)  

Added  a  parallel  API  Dispatcher  (ysfAPIClientPlugin)  Added  dimensions  to  configuraBons  

(ysfDimensionsPlugin)  Integrated  R3  translaBon/template  management  

(ysfR3Plugin)  R3  -­‐  hDp://developer.yahoo.com/r3/    

Created  a  build  and  deployment  soluBon  (ysfBuildPlugin)  Uses  internal  tools  for  packaging/deployment  

Integrate  support  for  Y!  User  Interface  libraries  (ysfYUIPlugin)  

Page 41: Building a platform from open source

Propel  or  Doctrine  or  ???  

No  ORM  for  large  projects  Doctrine  for  medium  sized  projects  Service  Oriented  Architecture  

Pla+orms/Data  as  services  Thin  Controller/Fat  Model  Use  PHP  as  the  frontend  glue  

No  heavy  li]ing  in  PHP  =  Push  down  the  stack  

Java/C++/Erlang  +  JSON/XML  

Page 42: Building a platform from open source

Localizing  with  dimensions  Cascading  ConfiguraBon  based  on  YAML  

Framework  -­‐>  Project  -­‐>  ApplicaBon  -­‐>  Module  Extending  the  cascade  to  be  based  on  dimensions  Dimensions  can  be  anything  (and  can  be  chained  together)  Data  Center  +  Environment  for  customizing  configuraBons  

Culture  for  localizing  user  interface  +  data  Theme  for  customizing  look  and  feel  User  info  (is  user  on  corporate  intranet?)  

Caching  

Page 43: Building a platform from open source

Development  Tools  

Page 44: Building a platform from open source

A  build  and  deployment  system  Aggregate  and  minify  stylesheets  and  javascripts  Rewrite  templates,  css,  js  for  CDN  (Akamai,  S3,  …)  Generate  translaBons  for  configuraBons  +  templates  Generate  configuraBon  cache  Aggregate  core  classes  +  remove  debug  statements  Run  lint,  unit,  funcBonal  tests  Package  applicaBons  as  .tgz  Deployment  via  packages  

Page 45: Building a platform from open source

Performance  

Hello  world  benchmarks  are  not  useful  You  do  not  use  a  framework  to  write  hello  world  

die(‘hello  world’);  

Performance  is  relaBve  to  the  features  you  use  ORM  I18N  Output  Escaping  Forms/ValidaBon    

Ability  to  scale  !=  performance  

Page 46: Building a platform from open source

What  does  it  mean  to  scale?  

A  system  whose  performance  improves  a]er  adding  hardware,  proporBonally  to  the  capacity  added,  is  said  to  be  a  scalable  system.  

High  Availability  +  Scalability  +  Performance  Bigger  dataset,  more  traffic,  maintainable  Not  about  performance  

PHP  is  slow,  but  it  is  very  rarely  your  boDleneck  

Languages  do  not  scale,  architectures  do  

Page 47: Building a platform from open source

Scaling  –  The  basics  in  PHP    PHP  is  rarely  the  boDleneck  (even  though  it  can  be  slow)  “Most  performance  comes  not  from  the  language,  but  from  applicaBon  

design”  –  Rasmus    Share  Nothing  Architecture  Independent,  self-­‐sufficient,  no  single  point  of  contenBon  No  local  storage  =  No  PHP  Sessions  

Use  a  database  Use  a  small  signed  cookie  (beDer)  

Important  data  in  database  Individual  expiraBon  on  session  objects  Small  data  items  

Use  an  in-­‐memory  cache  Memcache  

 Premature  opBmizaBon  is  the  root  of  all  evil.  “  vs.  ‘,  echo  vs.  print  

 

 Improve  performance  by  queuing  jobs  that  can  take  a  long  Bme  and  caching  data  that  is  expensive  to  query  

Page 48: Building a platform from open source

Once  an  app  has  a  well  designed  architecture,  developers  can  focus  on  

performance  specific  to  the  app  

Page 49: Building a platform from open source

Use  Xdebug/Webgrind  and  XHProf  to  debug  and  profile  applicaBon  

performance  

Page 50: Building a platform from open source

hDp://xdebug.org/docs/profiler  

Page 51: Building a platform from open source
Page 52: Building a platform from open source
Page 53: Building a platform from open source

Web  applicaBon  performance  isn’t  just  about  the  backend,  a  lot  of  open  source  tools  can  help  improve  the  frontend.  

Page 54: Building a platform from open source
Page 55: Building a platform from open source
Page 56: Building a platform from open source
Page 57: Building a platform from open source

As  the  framework  matured  and  gained  recogniBon  more  companies  started  

choosing  symfony    

Page 58: Building a platform from open source
Page 59: Building a platform from open source
Page 60: Building a platform from open source
Page 61: Building a platform from open source
Page 62: Building a platform from open source

At  Yahoo  scaling  applicaBons  was  easy:  infrastructure/process  already  exists  

Page 63: Building a platform from open source

As  I  work  on  my  own  startup  I  realized  I  need  to  create  the  same  scalable  and  fault  tolerant  environment,  except  without  invesBng  millions  of  dollars.  

Page 64: Building a platform from open source

A  quality  pla+orm  is  built  from  best  pracBces  

Page 65: Building a platform from open source

OperaBonal  Best  PracBces  

•  Global  data  centers  for  performance  and  fault  tolerance  

•  Automated  provisioning  of  networks,  servers,  storage,  etc.  

•  Automated  builds  +  deployments  •  Monitoring  +  ReporBng  (performance/

costs)  •  Centralized  Logging  +  Management  

Page 66: Building a platform from open source

Development  Best  PracBces  

•  Clean  /  Decoupled  /  Documented  code  •  Stand  on  the  shoulders  of  giants  •  Leverage  open  source  communiBes  

 

•  Source  Control  +  Project  Management  •  Unit  +  FuncBonal  TesBng  •  ConBnuous  IntegraBon  •  Either  you  are  always  ready  to  deploy  or  you  

are  never  ready  to  deploy  

Page 67: Building a platform from open source

Do  it  yourself  for  cheap  

Open  source  so]ware  =  Free  •  Linux  •  Apache  •  PHP  •  MySQL  /  Mongo  •  Memcache  /  Gearman  •  symfony  /  Doctrine  /  Twig  /  Swi]  /  

PHPUnit  

Page 68: Building a platform from open source

Today  it  is  possible  for  anyone  to  scale  a  web  pla+orm  just  like  a  big  company.  

Page 69: Building a platform from open source

Welcome  to  the  cloud.  

Page 70: Building a platform from open source
Page 71: Building a platform from open source
Page 72: Building a platform from open source

It’s  so  cheap  its  free!      

Who  doesn’t  love  free?  

Page 73: Building a platform from open source
Page 74: Building a platform from open source

hDp://aws.amazon.com/free  

Page 75: Building a platform from open source
Page 76: Building a platform from open source
Page 77: Building a platform from open source
Page 78: Building a platform from open source
Page 79: Building a platform from open source
Page 80: Building a platform from open source
Page 81: Building a platform from open source
Page 82: Building a platform from open source

A  load  balanced  cluster  with  a  relaBonal  database  and  storage  configured  how  ever  you  want  in  

mulBple  data  centers  around  the  world.  

Page 83: Building a platform from open source

For  free.  And  then  for  relaBvely  cheap.  

Page 84: Building a platform from open source

Its  not  fair!  Only  for  new  customers.  

Page 85: Building a platform from open source

A  way  to  monitor  and  manage  your  cloud  

Page 86: Building a platform from open source
Page 87: Building a platform from open source
Page 88: Building a platform from open source
Page 89: Building a platform from open source

A  free  global  DNS  cloud  service  

Page 90: Building a platform from open source
Page 91: Building a platform from open source

A  free  source  control  +  issue  tracking  service  that  enables  public  or  private  

collaboraBon  

Page 92: Building a platform from open source
Page 93: Building a platform from open source

A  complete  pla+orm  for  developing,  tesBng,  and  deploying  scalable  web  

applicaBons.  

Page 94: Building a platform from open source

Free  cloud  infrastructure:    Amazon  +  Zerigo  +  Landscape  

 Free  open  source  code:  

 Symfony  +  Zend  +  YUI  +  AlloyUI    

Free  development  tools:    GitHub  +  Xdebug  +  PHPUnit  

 Built  in  best  pracBces  +  support  

Page 95: Building a platform from open source

Many  lessons  have  been  learned  and  a  beDer  pla+orm  has  evolved.  

Page 96: Building a platform from open source

Symfony2  and  YUI3  

Page 97: Building a platform from open source

BeDer  Components:    lighter,  faster,  cleaner  

 BeDer  Development  Model:    ConBnuous  IntegraBon    BeDer  tesBng/documentaBon  

 Stronger  CommuniBes:    Github  enables  contribuBons    Galleries  for  plugins/bundles  

Page 98: Building a platform from open source
Page 99: Building a platform from open source
Page 100: Building a platform from open source
Page 101: Building a platform from open source
Page 102: Building a platform from open source
Page 103: Building a platform from open source

Symfony  

Symfony  2  is  a  set  of  cohesive  yet  decoupled  components  Easier  to  use  a  component  to  solve  a  single  problem  

Easier  to  build  micro  frameworks  that  solve  specific  problems  

Teams  generally  prefer  soluBons  that  are  specific  to  their  exact  problem  Selling  the  full  stack  can  be  difficult  when  a  team  only  wants  a  few  components       symfony-reloaded.org

Page 104: Building a platform from open source
Page 105: Building a platform from open source
Page 106: Building a platform from open source

Symfony2  stands  on  the  shoulders  of  giants  and  doesn’t  reinvent  the  wheel.  

Page 107: Building a platform from open source
Page 108: Building a platform from open source
Page 109: Building a platform from open source
Page 110: Building a platform from open source
Page 111: Building a platform from open source

We  even  use  Zend  Framework  

Page 112: Building a platform from open source
Page 113: Building a platform from open source

Symfony2  is  so  good  it  is  only  alpha  and  there  are  already  major  sites  live  in  

producBon.  

Page 114: Building a platform from open source
Page 115: Building a platform from open source
Page 116: Building a platform from open source
Page 117: Building a platform from open source
Page 118: Building a platform from open source
Page 119: Building a platform from open source

Take  a  look  at  the  Symfony2  web  profiler  

Page 120: Building a platform from open source
Page 121: Building a platform from open source
Page 122: Building a platform from open source
Page 123: Building a platform from open source
Page 124: Building a platform from open source

Take  a  look  at  the  Symfony  sandbox!  

Page 125: Building a platform from open source

github.com/symfony/symfony-­‐sandbox  

Page 126: Building a platform from open source
Page 127: Building a platform from open source

QuesBons?  

Page 128: Building a platform from open source

Hiring!  

If  you  are  a  great  developer  looking  to  make  your  next  move,  let  me  introduce  you  to:  

 Plancast  TripIt  Awesm  OpenSky  Gogobot