Ways to Improve Laravel Performance

Over the past few months my Weather Extension has grown to over 118,000+ users and averages 14 req/sec. Weather uses Laravel primarily as an api and VueJs to render the html. Speed is very important. Currently Weather is hosted on a $40 a month Digital Ocean server. Since Weather is free, I’ve tried my best to keep cost low. Here are a few changes I’ve made to improve the performance of my Laravel app.

  • Use caching whenever possible. I cache user data, settings and locations. This limits the amount of sql queries. Just make sure you invalidate the cache when the data changes.
  • Make sure you have good indexes for your database
  • Cache your configs, routes and views. Add these commands to your Forge deploy script. Read more about config caching here
    php artisan config:clear
    php artisan route:cache
    php artisan view:clear
  • Install/Setup PHP OPcache. OPcache will cache your php code so it doesn’t have to recompile. Check out this guide.

I would love to hear what you have done to improve speed and performance for your Laravel app. Please leave a comment below.

 


Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LYWeather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.  

Leave a Reply

Your email address will not be published. Required fields are marked *