Hello!
I am Nuruzzaman Milon
Senior Software Engineer @Telenor Health A\S
@to_milon
https://milon.im
Slide 3
Slide 3 text
I wrote a book on
laravel
ISBN: 978-984-33-9190-2
Buy @ https://milon.im/laravel
Slide 4
Slide 4 text
Sharing My
There is no golden rule, you might have different
opinion. Let me learn from you.
Slide 5
Slide 5 text
Minimize plugins usage
× Don’t use unnecessary plugins.
× Don’t import the whole library just for
using a single functionality.
Slide 6
Slide 6 text
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()`
Slide 7
Slide 7 text
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.)
Slide 8
Slide 8 text
Use http2
× Use server push to load static assets.
× Use CDN. (if possible)
Slide 9
Slide 9 text
Optimize Autoloader
× Optimize your autoload file
× Use either
`composer dump-autoload -- optimize`
Or
`composer dump-autoload
--classmap-authoritative`
Slide 10
Slide 10 text
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
Slide 11
Slide 11 text
Remove unused services
× Comment `ServiceProvider` those are
not in use.
× Use `Deferred` Service Providers.
Slide 12
Slide 12 text
Use Faster Drivers
× Use redis driver for session.
× Use memcached/redis driver for cache.
× Use Redis, where you can.
Slide 13
Slide 13 text
Profile your query
× Inspect your query.
× Use a good profiler. (Blackfire)
× Use a debugbar while developing.
× Cache your query.
Slide 14
Slide 14 text
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)
Slide 15
Slide 15 text
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.)
Slide 16
Slide 16 text
Consider lumen
× Consider micro services.
× Don’t built just another monolithic
application.
× Decide wisely. (or cautiously?)
× Avoid NANO services.
Slide 17
Slide 17 text
Place your screenshot here
You Ain’t Gonna
Need It.
Slide 18
Slide 18 text
THANKS!
Any questions?
You can find me at -
@to_milon
[email protected]
https://speakerdeck.com/milon/high-performance-laravel
??