Slide 1

Slide 1 text

Lesara as  a  fast  retail  online  pioneer 1 Knowledge  Session  – Performance  Optimization 2016-­‐04-­‐13

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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