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

High Performance Laravel

High Performance Laravel

Use Laravel to build high-performance web application.

Nuruzzaman Milon

November 18, 2017

More Decks by Nuruzzaman Milon

Other Decks in Technology


  1. High performance Laravel

  2. Hello! I am Nuruzzaman Milon Senior Software Engineer @Telenor Health

    A\S @to_milon https://milon.im
  3. I wrote a book on laravel ISBN: 978-984-33-9190-2 Buy @

  4. Sharing My There is no golden rule, you might have

    different opinion. Let me learn from you.
  5. Minimize plugins usage × Don’t use unnecessary plugins. × Don’t

    import the whole library just for using a single functionality.
  6. Use Eager loading × Try to avoid N+1 problem ×

    Don’t load the whole collection, if you just need the count. × Use `select()` rather than `all()`
  7. Trim your response × Don’t try to render all the

    elements at a time, use pagination or lazy loading. × Don’t return, what you don’t need. × Use transformer. (Fractal, Resource etc.)
  8. Use http2 × Use server push to load static assets.

    × Use CDN. (if possible)
  9. Optimize Autoloader × Optimize your autoload file × Use either

    `composer dump-autoload -- optimize` Or `composer dump-autoload --classmap-authoritative`
  10. Cache routes and configs × Cache your routes file- `php

    artisan route:cache` × Cache your config file- `php artisan config:cache` × Don’t use `env()` function
  11. Remove unused services × Comment `ServiceProvider` those are not in

    use. × Use `Deferred` Service Providers.
  12. Use Faster Drivers × Use redis driver for session. ×

    Use memcached/redis driver for cache. × Use Redis, where you can.
  13. Profile your query × Inspect your query. × Use a

    good profiler. (Blackfire) × Use a debugbar while developing. × Cache your query.
  14. Use queue for expensive task × Use queue for long

    running task. × Use queue for CPU or memory intensive tasks. × Return early, if it’s possible. × Use a good monitoring tool. (Horizon)
  15. Inspect Exceptions and Log × Use a good error reporting

    tool like Bugsnag, Sentry etc. × Log every possible failed scenario. × Use `logrotate` to manage log files. × Use benchmarking tool. (ab, wrk etc.)
  16. Consider lumen × Consider micro services. × Don’t built just

    another monolithic application. × Decide wisely. (or cautiously?) × Avoid NANO services.
  17. Place your screenshot here You Ain’t Gonna Need It.

  18. THANKS! Any questions? You can find me at - @to_milon

    [email protected] https://speakerdeck.com/milon/high-performance-laravel ??