We can test our Blackfire installation by profiling a built-in Artisan command. Homestead saves us a bit of time by coming with Blackfire pre-installed, but if you don’t have Blackfire installed yet then simply follow the instructions from the Blackfire docs (we need the agent, the CLI tool, and the PHP probe all to be installed). I’m going to assume you have your Laravel app already set up on Homestead (or your server). Once logged in, navigate to the account page where you should see your client credentials. If you haven’t done so already, head on over and sign up for a Blackfire account. For the purposes of this tutorial, we’re going to use a Laravel Homestead VM, but these instructions would apply for any server that you run your Laravel app on. The first thing we need to do is get Blackfire up and running on the server that is running our Laravel app. We will have a look at how we should interpret the results and see how I managed to improve the performance of Mergebot by 1200%. In this article, we’re going to look at how to profile a Laravel application and specifically how I profile a queue job using Blackfire. This is more than enough to get you going when you need to look for performance bottlenecks in PHP code. Blackfire’s premium plans offer all sorts of fancy performance monitoring features, which are definitely worth checking out, but their free plan allows you to profile web pages, CLI scripts, and API Calls allowing you to measure wall time and memory usage. My first port of call when it comes to profiling PHP applications is Blackfire. generating a deployment) so that the workload can be offloaded from the web server and scaled separately. We use Laravel’s Queue Jobs to handle any long-running processes (e.g. Enter, Laravel.Īs you probably know by now, the Mergebot application is built using Laravel. However, it became clear that we needed to do something about the performance of the app, especially the performance of our deployment generation jobs, to be able to lift the 1,000 queries per deployment limitation.Īs part of my work on lifting the limit, I needed to ensure that deployments wouldn’t just fail because of timeouts or hitting memory limits. When we were building Mergebot, the problems we were focused on solving were so complex that we didn’t really spend much time thinking about optimization or making our code run quickly. We created Mergebot to make merging WordPress databases easy. We just hit a huge milestone in our Mergebot beta by lifting the 1,000 queries per deployment limit.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |