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

    View Slide

  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

    View Slide

  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

    View Slide

  4. 4
    Application layer
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  5. 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

    View Slide

  6. 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

    View Slide

  7. 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

    View Slide

  8. Synchronous vs.  Asynchronous
    8
    Synchronous Asynchronous  with  using  a  Message  Queue
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  9. Use profiling to learn about the behaviour
    9
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM
    • Xdebug
    • PHP  Storm

    View Slide

  10. Use NewRelic for production environment
    10
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  11. 11
    Database  layer
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  12. 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

    View Slide

  13. 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

    View Slide

  14. 14
    Infrastructure  layer
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  15. 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

    View Slide

  16. 16
    Caching  layer
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  17. 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

    View Slide

  18. The  hard parts of caching
    18
    • Cache  invalidation
    • Hole  punching using AJAX  or ESI
    Cached
    Uncached
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  19. Thanks for listening
    19
    @_RobM
    https://de.linkedin.com/in/robin-­‐müller-­‐729a2b19
    www.lesara.com
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide

  20. Sources
    20
    https://www.phase2technology.com/blog/profiling-­‐drupal-­‐performance-­‐with-­‐phpstorm-­‐and-­‐xdebug/
    http://use-­‐the-­‐index-­‐luke.com
    https://www.percona.com/blog/2013/09/20/innodb-­‐performance-­‐optimization-­‐basics-­‐updated/
    http://fbrnc.net/blog/2011/05/make-­‐your-­‐magento-­‐store-­‐fly-­‐using-­‐varnish#hello
    https://www.rabbitmq.com/tutorials/amqp-­‐concepts.html
    2016-­‐04-­‐13  |  Robin Müller  |@_RobM

    View Slide