Is your application running slow? If your users are reporting slower response times, or better, you are measuring response times using a monitoring tool, this here is are some checklist items to go through to asses.
There are different application monitoring tools which can help in troubleshooting the performance problem. My favorite is NewRelic, but there is AppDynamics, SolarWinds and more. Following are some ways on how to get started with NewRelic for debugging any performance problem –
- Application Overview: This gives a clear picture of application performance. Some of the important things that you can check here are web transaction time, Apdex score, throughput, and transaction. For more details read this.
- Transactions: This will help you in finding out some of the key transactions and time taken for those transactions. On this page, you can check which application URL is the most time consuming and have a complete breakdown on how much time is getting consumed at which level. For more details read this.
- Databases: Databases page shows top database operations by time consumed. It shows the throughput and average time taken for each query. For more details read this. One of the most important thing that you can do is enable slow query log once they are recorded you can find all slow queries under slow query tag at the bottom. read this for more detail.
- External Integration: External integration page records all out-of-process services such as web services, resources in the cloud, and any other network calls. You can find if there any integration which is consuming most of the time. read this for more details.
The performance of the system is heavily dependent on the amount of time we talk to the DB as the DB is bottleneck most of the time. Here are a few important points things to ensure while writing queries or code reviewing
- Never write queries inside FOR loop. Query all the data that you need and then do the parsing in memory
- Use slow query logs and find out all slow queries
- Make sure all the tables are properly indexed, it plays a big role in performance once you have a huge amount of data
- Write well formed SQL queries pay more attention to WHERE and GROUP BY clauses
- Make sure that there are no subqueries within IN clause
- Run EXPLAIN for all queries, number of row scanned and cardinality should be less
- Connection should be pooled, with the use of connection pool you don’t need to create and destroy MYSQL connections every time
- Use caches to store the reference data or very frequently accessed data
- Tune mysql parameters for better performance, it becomes more important if your application deals with a huge volume of data
The best way to check any web page performance is by using google chrome profiler. You will get a pretty clear picture about any web page. There are also various online websites you can use for performance testing (i.e. – pingdom, webpagetest). Except that, the following are a few points that you should take care while debugging any page load performance issue –
- Reduce the number of HTTP calls to load a page
- Use server side rendering if you can, It will help to avoid AJAX calls
- Keep all the stylesheet in the document HEAD element, this will help to load a page quicker since this allows pages to render progressively
- Load JS files asynchronously
- Use minify JS and CSS
- Enable Gzip compression
- Use sprite for combining images into one image
- Use cache as much as you can
- Reduce latency with a Content Delivery Network (CDN)
In case you are a WordPress user and If you’re looking for ways to speed up your WordPress site performance, then this article may help.