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
Tweet

More Decks by Nuruzzaman Milon

Other Decks in Technology

Transcript

  1. High
    performance
    Laravel

    View Slide

  2. Hello!
    I am Nuruzzaman Milon
    Senior Software Engineer @Telenor Health A\S
    @to_milon
    https://milon.im

    View Slide

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

    View Slide

  4. Sharing My
    There is no golden rule, you might have different
    opinion. Let me learn from you.

    View Slide

  5. Minimize plugins usage
    × Don’t use unnecessary plugins.
    × Don’t import the whole library just for
    using a single functionality.

    View Slide

  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()`

    View Slide

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

    View Slide

  8. Use http2
    × Use server push to load static assets.
    × Use CDN. (if possible)

    View Slide

  9. Optimize Autoloader
    × Optimize your autoload file
    × Use either
    `composer dump-autoload -- optimize`
    Or
    `composer dump-autoload
    --classmap-authoritative`

    View Slide

  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

    View Slide

  11. Remove unused services
    × Comment `ServiceProvider` those are
    not in use.
    × Use `Deferred` Service Providers.

    View Slide

  12. Use Faster Drivers
    × Use redis driver for session.
    × Use memcached/redis driver for cache.
    × Use Redis, where you can.

    View Slide

  13. Profile your query
    × Inspect your query.
    × Use a good profiler. (Blackfire)
    × Use a debugbar while developing.
    × Cache your query.

    View Slide

  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)

    View Slide

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

    View Slide

  16. Consider lumen
    × Consider micro services.
    × Don’t built just another monolithic
    application.
    × Decide wisely. (or cautiously?)
    × Avoid NANO services.

    View Slide

  17. Place your screenshot here
    You Ain’t Gonna
    Need It.

    View Slide

  18. THANKS!
    Any questions?
    You can find me at -
    @to_milon
    [email protected]
    https://speakerdeck.com/milon/high-performance-laravel
    ??

    View Slide