Author: Manuel Lemos
Viewers: 147
Last month viewers: 15
Categories: PHP Tutorials, PHP Performance, Lately in PHP Podcast, Sponsored
If there are many parts of your application that you need to optimize, the next decision is which parts you should work to optimize first.
Fortunately, some profiling tools can help you figure out which parts of your application you need to optimize first.
Please read this short article to learn how to use the Scout Application Performance Monitoring tool to determine which parts of a Laravel or Symfony application you should optimize to achieve the most significant performance improvements sooner.
In this article you will learn about:
1. Why You Need to Find the Slowest Parts of Your Application Is the First Step
2. What Should You to Find the Slowest Parts of a Web Application
3. How You Can Find The Slowest Parts of Each of Your Application Scripts
4. How You Can Quickly Find the Slowest Parts of Each of Your Application Scripts Using A Profiling Tool
1. Why You Need to Find the Slowest Parts of Your Application Is the First Step
The effort to optimize your application can have a significant impact on the usability of the application and the satisfaction of the users. Satisfied users will be motivated to continue using your application.
If you have a paid application, satisfied users will keep paying you. That will help to make your business financially viable for a long time.
If you have many slow parts in your application, you need to decide which parts you should give priority to your optimization efforts.
The first parts you should optimize are the ones on which most of your users spend more time waiting for your application because if they take too much time, users without patience will give up using it.
2. What Should You to Find the Slowest Parts of a Web Application
What you can do to find slow parts of your application is to measure the time each part of your Web application takes to serve HTTP requests to users.
Then you need to sort the list of HTTP request URLs by those that take more time to finish. You also need to count how many times the HTTP request URLs that are more important for your users are accessed.
If you add the times of all requests sent to the same URLs, you can calculate a time factor that you can use to sort the list of HTTP request URLs by descending order of the time factor.
The first HTTP request URLs in that list are those that are the slowest parts of your application.
Then you need to discover the slowest parts of the slowest scripts that handle the HTTP requests sent to the slowest URLs of your Web application.
3. How You Can Find The Slowest Parts of Each of Your Application Scripts
As I mentioned in a previous article about How to Use a PHP Application Profiling Tool to Determine What You Should Optimize First to Improve the Performance of a Laravel or Symfony Application Performance, one common technique that many PHP developers use to find out the slowest parts of their applications requires using a benchmark script that measures the time it takes to execute each part of your code that you suspect to be the slowest.
On the PHP Classes site, you may find a few classes to measure the time a part of your script takes to execute.
This approach can work to measure the time that a script takes to execute, starting at one point of the script and ending at another point of that script.
Since we need to find the slowest parts of your script, you can add more measure points to narrow the search for the slowest parts of your script code.
Although this technique may work in some cases, you may need to spend a lot of time measuring the time that each part of your application script takes to execute while the application users are waiting.
4. How You Can Quickly Find the Slowest Parts of Each of Your Application Scripts Using A Profiling Tool
If you have a problem that takes a lot of time to solve, often you can reduce the time to solve that problem using a specialized tool that reduces part of the time needed to implement a solution.
As I explained in a previous article, profilers are tools that can help reduce the time to optimize slow applications.
You can use a profiler application to collect code execution data. Then the tool can analyze the collected data to find the slowest parts of the application code that are making the user wait more time to be ready to use.
Using either Laravel or Symfony frameworks to develop your applications, you can use a tool like {link:153:ScoutApplicationMonitoring} to profile PHP applications based on these frameworks.
{link:156:ScoutApplicationMonitoring} is a tool that not only can help find slow application scripts, but you can also find the slowest parts of each script following a few steps to narrow the search for the slowest code.
In the following weeks, there will be more to say about Scout Application Monitoring. For now, I invite you to watch this video of a Demo of Scout in PHP. Watching this video, you can learn how to narrow the search for slow code in a PHP Laravel or Symfony application.
Then you can also try this tool for free during a trial period so you can use it yourself in real Laravel or Symfony applications that you developed.
You need to be a registered user or login to post a comment
1,616,811 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
1. PHP performance upgrade - Hobby turysta (2022-08-19 08:32)
performance metrics... - 1 reply
Read the whole comment and replies