Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building A Platform From Open Source At Yahoo


Published on

Building a platform from symfony at Yahoo!

Presented at symfonyLive 2010 in Paris, France by Dustin Whittle.

Join us for a case study on using open source tools to build a platform for enterprise web applications with symfony. The focus of this session will be on how Yahoo! has built web applications that scale with symfony. Find out what worked and what didn't when building scalable web applications with the symfony framework.

* Why symfony?
* symfony vs ysymfony
* Social Search: Delicious and Answers
* YOS: Developer Tool & Application Platform
* Internal Tools: Customer Care + Dashboards
* The Platform + Components
* Yahoo! symfony Plugins
* Developer Tools - YUI3, YQL, Design Patterns, etc

Published in: Technology, Education

Building A Platform From Open Source At Yahoo

  1. Building a platform from open source<br />Dustin Whittle<br />
  2. Overview<br />Why symfony?<br />symfony vs. ysymfony<br />What does scaling really mean?<br />Social Search: Delicious and Answers<br />International:, FoxyTunes,<br />Yahoo! Open Strategy<br />What is the Yahoo! Open Stack?<br />Developer Tools<br />YUI, Design Patterns, Tutorials<br />Data & Social APIs<br />YQL: Yahoo! Query Language<br />Profiles, Connections, Updates, …<br />Geo, Flickr, Delicious, Upcoming<br />YOS SDK for PHP<br />
  3. Who am I?<br />Working with symfony since open source<br />symfony Core Team Member<br />Responsible for the development and support of ysymfony at Yahoo!<br />Worked with Y! Answers, Delicious, Y! Widgets, Y! Bookmarks, Yahoo! Application Platform<br />Developer advocacy for Yahoo! Developer Network<br />Consultant<br />Commercial symfony support + training (USA)<br />
  5. Freebsd | linux | apache | php | mysql | BUGZILLA | hadoop | symfony<br />Yahoo! Is powered by open source technologies<br />
  6. W3C | MICROFORMATS | OAUTH | OPENID | OPENSOCIAL<br />YAHOO! embraces open standards<br />
  7. YUI | BROWSER PLUS | DESIGN PATTERNS | R3 | YSLOW + PERFORMANCE RULES<br />YAHOO! gives back to open source<br />
  9. Conferences | Hack Days | HackU | Tech Talks | YDN Theater<br />YAHOO! ENGAGES COMMUNITIES WITH OPEN HACK EVENTS around the world<br />
  10. Users<br />LoadBalancers<br />Frontend<br />Backend<br />Linux<br />ysymfony/ YUI<br />Apache<br />Custom Modules<br />PHPAPC, PEAR, PECL, Custom Extensions<br />UserAPI<br />MySQL/Memcache<br />Web Services<br />Ad API<br />
  11. Why a frontend platform?<br />Rasmus says “frameworks are not well suited for Yahoo!”<br />Build applications to requirements<br />Do exactly what you need: no more, no less<br />Understand that frameworks add a lot of overhead<br />Choosing functional components is a better fit<br />Despite choosing open source or building your own<br />Everyone uses a framework<br />If you use open source, use only the pieces you need<br />
  12. Y! needs from a frontend platform<br />Fit existing environment (RHEL/PHP5/Apache)<br />Development Cycle – How easy to develop, test, and deploy?<br />Clean separation between data, logic, and display (MVC) <br />Independent model layer to fit service oriented architecture<br />Extensible and pluggable<br />Internationalization and localization support<br />Detailed documentation and active community of support<br />Open source and ability to contribute back<br />
  13. Why a framework at all?<br />Another software layer (ysymfony, yphp, yapache)<br />Factors out common patterns<br />Code Layout<br />Configuration<br />URL Routing<br />Authentication / Security<br />Form Validation / Repopulation<br />Internationalization / Localization<br />Encourages good design<br />Abstraction &gt; Consistency &gt; Maintainability<br />
  14. The choice to adopt symfony?<br />Philosophy<br />Full-stack framework for building complex web applications<br />Adopt best ideas from anywhere, using existing code if available (Mojavi, Prado, Rails, Django)<br /> Design<br />Clean separation between Model, View, and Controller<br />Controller using modules and actions<br />Views using templates in straight PHP with helpers<br />Easy to reuse view modules to compose a page<br />Layouts, Components, Partials, Slots<br />
  15. The choice to use symfony<br />Configurability / Flexibility<br />Features we do not want are easily disabled<br />Use of factories for easy customization<br />Documentation / Support Community<br />The Definitive Guide to symfony<br />Askeet, Jobeet, Cookbooks, Advents<br />Active community with wiki, mailing lists, forums, irc channel<br />
  16. Why ysymfony for Yahoo! teams?<br />Eliminate common patterns by adding a layer on PHP<br />Code layout/structure (MVC)<br />Configuration<br />Internationalization<br />ysymfony is just a toolkit<br />Learn one set of tools<br />Shift between multiple projects<br />Consistency<br />Long term maintainability through platform<br />
  17. How Yahoo! uses symfony<br />Full Stack<br />Yahoo! Bookmarks<br />Yahoo! Answers<br />Delicious<br />Yahoo! Widgets<br />Yahoo! Application Platform<br />, Foxytunes,<br />Internal Dashboards + Reporting Tools<br />Components<br />Dependency Injection<br />Forms<br />Caching (APC/Memcache)<br />Routing<br />
  18. symfony MVC framework<br />
  19. A look at Yahoo! Answers<br /><br />Yahoo! Answers is the largest collection of human knowledge on the Web with more than 135 million users and 515 million answers worldwide (Yahoo! Internal Data, March 2008).<br />Yahoo! Answers is the 2nd ranked education & reference site on the web (comScore)<br />Available in 26 markets and 12 languages<br />
  20. Yahoo! Answers at the beginning<br />Started as a small development team on PHP4 from a fork of Yahoo! Taiwan Knowledge+<br />Launched December 2005 by December 2006 there were 60 million users and 65 million answers<br />The code base eventually became difficult to maintain and iterate new features<br />Large distributed development teams (US / UK)<br />
  21. The big picture<br />A complete platform for building web applications from frameworks<br />PHP Framework<br />JavaScript Framework<br />CSS Framework<br />UI Design Patterns + Best Practices<br />Development Tools (logger, profiler, debugger, docs)<br />Unit + Functional Testing Frameworks (LIME / YUI Test)<br />Deployment Tools (rsync deployment system)<br />
  22. What does Yahoo! change?<br />Minor changes to fit our environment<br />Most changes are easily implemented via factories/plugins<br /> Dropped the ORM and pushed down the stack (SOA)<br />Added a parallel API Dispatcher (ysfAPIClientPlugin)<br />Added dimensions to configurations (ysfDimensionsPlugin)<br />Integrated R3 translation/template management (ysfR3Plugin)<br />R3 - <br />Created a build and deployment solution (ysfBuildPlugin)<br />Uses internal tools for packaging/deployment<br />Integrate support for Y! User Interface libraries (ysfYUIPlugin)<br />
  23. Propel or Doctrine or ???<br />No ORM for large projects<br />Doctrine for medium sized projects<br />Service Oriented Architecture<br />Platforms/Backendsas services (reusable to all)<br />Thin Controller/Fat Model (where model == services)<br />Use PHP as the frontend glue<br />No heavy lifting in PHP = Push down the stack<br />Java/C++/Erlang + JSON/XML<br />
  24. Localizing with dimensions<br />Cascading Configuration based on YAML<br />Framework -&gt; Project -&gt; Application -&gt; Module<br />Extending the cascade to be based on dimensions<br />Dimensions can be anything (and can be chained together)<br />Data Center + Environment for customizing configurations<br />Culture for localizing user interface + data<br />Theme for customizing look and feel<br />User info (is user on corporate intranet?)<br />Caching<br />
  25. symfony I18n + L10n<br />Translation + Template Management<br />Integrated with symfony i18n + view layers<br />&lt;r3:trans&gt;hello&lt;/r3:trans&gt; vs __(‘hello’)<br />Dictionary Management (YALA)<br />SQLite/XLIFF Backend<br />Added additional tasks<br />Importing/Exporting XLIFF dictionary<br />Generating sample translations for projects<br />Find missing strings<br />
  26. A build and deployment system<br />Aggregate and minify stylesheets and javascripts<br />Rewrite templates, css, js for CDN (Akamai, S3, …)<br />Generate translations for configurations + templates<br />Generate configuration cache<br />Aggregate core classes + remove debug statements<br />Run lint, unit, functional tests<br />Package applications as .tgz<br />Deployment via packages<br />Integrated with Yahoo! internal tools<br />
  27. Hello World Performance<br />Hello world benchmarks are generally not a useful measurement<br />You don’t use a framework to write hello world<br />die(‘hello world’);<br />Performance is relative to the features you use<br />ORM<br />I18N<br />Output Escaping<br />Forms/Validation<br />Ability to scale != performance<br />
  28. What does it mean to scale?<br />A system whose performance improves after adding hardware, proportionally to the capacity added, is said to be a scalable system.<br />High Availability + Scalability + Performance<br />Bigger dataset, more traffic, maintainable<br />Not about performance<br />PHP is slow, but it is very rarely your bottleneck<br />Languages do not scale, architectures do<br />Planning to grow and planning to fail<br />Capacity Planning<br />Business Continuity Planning<br />
  29. Scaling – Planning<br />Planning hardware purchases and hosting options to have as much as you need without breaking your wallet<br />Partitioning and distributing databases to support large datasets and simultaneous transactions<br />Offline transactions and queuing<br />Monitoring your applications to find and clear bottlenecks<br />Providing service APIs and using services from other providers to increase your site&apos;s reach and capabilities<br />Think Minimal, Plan to grow, Plan to fail<br />
  30. Scaling – The basics in PHP<br />PHP is rarely the bottleneck (even though it can be slow)<br />“Most performance comes not from the language, but from application design” – Rasmus<br />Share Nothing Architecture<br />Independent, self-sufficient, no single point of contention<br />No local storage = No PHP Sessions<br />Use a database (works for distributed)<br />Use a small signed cookie (ideal)<br />Important data in database<br />Individual expiration on session objects<br />Small data items<br />Use a distributed cache<br />Memcache<br />Forget about small efficiencies<br />Premature optimization is the root of all evil.<br />“ vs. ‘, echo vs. print<br />
  31. Scaling Databases – The basics<br />Drop the ORM<br />It’s a choice of convenience over performance<br />Master/Slave Replication<br />First steps<br />Helps with reads, writes are still bottleneck<br />Partitioning<br />Segmenting data<br />Sharding (horizontal partitioning)<br />Segmenting data onto different physical machines<br />Make problems smaller, easier to grow<br />
  32. Improving latency with Caching<br />Always use PHP opcode cache (APC, Xcache, etc)<br />Use for routing and i18n cache<br />Memcache (distributed cache)<br />Use for view cache<br />Distributed invalidation can be a pain<br />sfViewCacheManager makes this easy!<br />Be intelligent about cache_keys (uri, user, state)<br />There is a fine line to caching<br />At what point do you spend more time managing the cache, than reading from it?<br />
  33. Tweaking Performance<br />Do not use .htaccess (move to real apache config)<br />Set a minimal include path<br />Increase realpath_cache_size + realpath_cache_ttl<br />Use apc.stat=0<br />Don’t use features you do not need<br />Disable in settings.yml/ factories.yml<br />Use core_compile to aggregate classes to reduce file i/o<br />Remove debug statements + optimize file lookups<br />sfOptimizerPlugin / project:optimize<br />Use @routeName and use caching for factories<br />
  34. Symfony (v2)<br />Symfony 2 is a set of cohesive yet decoupled components<br />This makes it much easier to use single component to solve a single problem<br />Which makes it easier to build micro frameworks that solve very specific problems<br />Yahoo! Teams generally prefer solutions that are specific to their exact problem<br />Selling the full stack can be difficult when a team only wants a few components<br />Symfony 2 is the right direction, even if it breaks backwards compatability<br />
  35. Do it yourself for cheap<br />Open source software = Free<br />Apache<br />PHP<br />MySQL<br />Memcache / Perlbal / MogileFS / Squid / Gearman<br />symfony / Doctrine / Propel / Swift<br />Nagios / Cacti<br />Amazon Shared Infrastructure = Cheap<br />EC2 Cloud<br />S3 Storage + Cloudfront<br />SimpleDB<br />
  36. Y! OS – The Open Stack<br />
  37. What Yahoo! offer developers<br /><ul><li>Yahoo! Developer Network
  38. Developer Tools (YUI, etc)
  39. Social APIs
  40. Profiles
  41. Connections
  42. Updates
  43. Data APIs
  44. Flickr, Delicious, Search, etc
  45. Yahoo! Query Language
  46. Yahoo! Application Platform
  47. OpenSocial</li></li></ul><li>
  48.<br />
  49. What is Yahoo! Developer Network?<br />The Yahoo! Developer Network offers open source tools and open data APIs to make it easy for developers to build applications and mashups.<br />50+ APIs / Web Services<br />Developer Dashboard to create/manage Oauth applications<br />Tutorials + Code Samples on using our apis<br />Complete API Documentation<br />Yahoo! User Interface libraries<br />ASTRA Flash Components<br />Design Patterns Library<br />Evangelism: Conferences / Theater / Blogs / Events<br />
  50. JavaScript Framework<br />Utilities - YAHOO, Dom, Event, Animation, Browser History Manager, Connection Manager, Cookie, DataSource, Drag and Drop, Element, Get, ImageLoader, JSON, Resize, Selector, Loader<br />Controls / Widgets - AutoComplete, Button, Calendar, Charts, Color Picker, DataTable, ImageCropper, Rich Text Editor, Slider, Uploader<br />Container (Module, Overlay, Panel, Tooltip, Dialog), Layout Manager, Menu, TabView, TreeView<br />Debug – Logger, Profiler, Test<br />Y! Developer Network – YUI Javascript<br />
  51. CSS Foundation<br />Reset - Neutralizes browser CSS styles<br />Base - Applies consistent style foundation<br />Fonts - Foundation for typography and font-sizing<br />Grids - Thousands of wireframe layouts<br />User Interface Design Patterns Library<br />Proven solutions to common interfaces<br /><br />Grade Browser Support / Progressive Enhancement<br />Y! Developer Network – YUI CSS<br />
  52. More than 275 functional examples<br /><br />YSlow + Performance Rules<br /><br />YUI Blog<br /><br />Mailing List @ Yahoo! Groups<br /><br />Y! Developer Network – Documentation<br />
  53. A Query Language for the Web<br />SELECT * FROM INTERNET<br />
  54. Thousands of web services that provide valuable data<br />Require developers to read documentation and form URLs/queries.<br />Data is isolated and can not be combined<br />Needs combining, tweaking, shaping even after it gets to the developer.<br />Before YQL<br />
  55. SQL-Like Language<br />Synonymous with Data access<br />Familiar to developers<br />Expressive enough to get the right data<br />Self Describing - show, desc table<br />Allows you to query, filter and join data across Web Services.<br />Y! Open Stack – YQL<br />
  56. YQL – Open Tables<br />Twitter<br />Google<br />Facebook<br />Friendfeed<br />Wesabe<br />Whitepages<br />Zillow<br />Search<br />Weather<br />Flickr<br />Upcoming<br />Delicious<br />Dopplr<br />Github<br />New York Times<br />Shopping<br />…any web service can be as easy as SQL<br />Available on github -<br />
  57. YQL – Open Tables<br />
  58. YQL – Open Tables<br />
  59. YQL – Open Tables<br />
  60. select * from social.connections<br />select * from delicious.feeds.popular<br />select * from<br />select * from friendfeed.status<br />select * from github.checkins<br />YQL - Examples<br />
  61. OAuth Endpoint<br /><br />Public Endpoint <br /><br />YQL Console <br /><br />YQL – API End Points<br />
  62. Books worth reading<br />
  63. (I will be around for the whole event, so please say hello and ask questions)<br />Questions?<br />
  64. enjoy the rest ofsymfonylive 2010<br />EXAMPLES | TUTORIALS | CODE SAMPLES<br /><br />
  65. Want to join Yahoo?We are hiring!<br />