Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance Optimization of Web Applications

Performance Optimization of Web Applications

Presentation of an internal tech talk at Lesara.

Robin Müller

April 13, 2016
Tweet

More Decks by Robin Müller

Other Decks in Technology

Transcript

  1. Lesara as  a  fast  retail  online  pioneer 1 Knowledge  Session

     – Performance  Optimization 2016-­‐04-­‐13
  2. Agenda 2 1  – Architecture  Overview 2  – How  to

     analyze  and  optimize  performance   2.1  – Application   2.2  – Database   2.3  – Infrastructure   2.3  – Caching   2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  3. Architecture 3 4 Start  with  your  Application Optimize  the  database

    Check  your  infrastructure Add  caching  if  necessary 1 3 2 5 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  4. What do  you need to check  in  your application? 5

    • Algorithms • Is the algorithm efficient? • How often does my code access the database?  (SLOW!) • Am  I  using the right tools to get the job done? • Sessions  MySQL  vs.  Redis vs.  File • Search/Catalog using MySQL  vs.  Elastic • Queues  in  MySQL  table vs.  RabbitMQ 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  5. Algorithm time  complexity 6 Analyze  your  algorithms Know  the  time

     complexity Dev  systems  might  not  have   enough  data  to  notice  slow   algorithms  during   development 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  6. Use loose coupling /  asynchronous flow 7 • Use a

     message queue and consumers to handle  all  tasks which can be async • Examples • Send  emails • Sync data to other systems • Each task can be scaled individually 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  7. Synchronous vs.  Asynchronous 8 Synchronous Asynchronous  with  using  a  Message

     Queue 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  8. Use profiling to learn about the behaviour 9 2016-­‐04-­‐13  |

     Robin Müller  |@_RobM • Xdebug • PHP  Storm
  9. Use the index,  Luke! 12 • Indexes • Are  the

    colums I  use for JOIN,  WHERE  and aggregations indexed? • Are  combined indexes performing better? 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  10. Configure your database 13 • InnoDB Storage  Engine  needs configuration!

    • innodb_buffer_pool_size • innodb_file_per_table • innodb_buffer_pool_instances • innodb_flush_method • Use the MySQL  query cache • Also  think about how your application affects the query cache 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  11. Optimize your servers 15 • Network • Bandwidth /  Performance

    • Packet  loss • Memory • Is there enough memory or does the system swap? • I/O • Is my application I/O  heavy? • Can  I  optimize that? • SSD  vs.  HDD 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  12. Think  about caching 17 • Different  cache types • MySQL

     query cache • Opcode cache • Application cache • Frontend  cache • Browser  cache 2016-­‐04-­‐13  |  Robin Müller  |@_RobM
  13. The  hard parts of caching 18 • Cache  invalidation •

    Hole  punching using AJAX  or ESI Cached Uncached 2016-­‐04-­‐13  |  Robin Müller  |@_RobM