Related Resources

Our Services

You May Also Like

Performance Optimization Techniques

Krunal Shah

Oct 03, 2017

4 min readLast Updated Sep 14, 2020

Performance Optimization Techniques

I am sure being a developer at some point of time we all encounter performance issues with the code we are developing. The issues with the performance comes in to play once we have scaled the project considerably. And having said that there comes the biggest fear for the developer to explore the 1000s of line of code just pin point that small area that is causing the entire application to slowdown. The task is not a walk on rose petals but its also not as harsh as a marathon in Sahara.

Now, before we start optimization, we need to figure our which is the possible area of the application causing the issue. Is it the front-end, service side or database side. Without knowing the area we cannot fix the problem.

Hence, the first step would be to understand and figure out the area of your application that is causing the issue. For example if your page is slow because of the database query and if you optimize the front-end or server side code it is not going to improve the performance at all.

Front-end performance optimization

Here I am going to explain what are steps we can take for optimizations.

Front-end performance optimization

  1. All the JS, CSS and HTML in the project must be minified
  2. The images that you have used should be optimized for the web
  3. Check are we not binding extra event listeners? If we are binding multiple listeners on a single page it will slow down the page.
  4. Avoid fetching unnecessary data. Only fetch data that you want to show on the page. If you need only 10 rows don’t fetch 1000 rows and display only 10.
  5. You can try HTTP2 instead of HTTP1
  6. Light house is a tool from google will give you a detailed idea about what improvements needs to be done. That’s a good way to start.
  7. Webpack is really great tool if you are not using it. This is the time to start using webpack.

Database side optimization

  1. Don’t fetch extra data, if you want to display only 2 columns of a specific table than fetch only 2 columns instead of all.
  2. Inner join is better than left join as inner join do less row scan compare to left Join. So, if you don’t need left join than go with the inner join.
  3. Always create index for foreign keys.
  4. Avoid writing queries in the loop.
  5. Execute the ‘Explain’ plan of your query to get the idea what is wrong with the query. Is, your query really using index or not? How many rows are getting scanned. And do not forget to create proper index depending upon the query.
  6. Explain plan will give you a detail idea about is your query using temporary table or not. If your query is using temporary table then try to fix that problem.
  7. Create a proper index depending upon the where condition in the query.

Server side optimization

  1. Make sure you are not using unnecessary loops.
  2. Check the methods you are using that is not causing the slowness.
  3. Make sure the libraries you are using are not causing the issues.
  4. Check is your server running multiple processes or multiple threads in production mode.
  5. Perform load balancing if your server is not sufficient to handle the data.
  6. Process the time consuming tasks in the background. So, the user doesn’t have to wait for a long time on the front .
  7. Avoid pull mechanism for notification as it will create unnecessary load on server. Push mechanism is the better solution for the notification.

Caching Techniques for performance optimization

  1. You can use low level caching to cache your database queries with memcache store.
  2. You can use page caching when you are serving static pages.
  3. You can use HTTP caching if data is not changed server will respond with 304.
  4. We can use fragment caching for the hybrid application. As people are moving to SPA there is not much importance of fragment caching for those applications.
  5. You can use memcache database as a non persistent database. Memcache will delete data automatically if user is not requesting specific data regularly and maintain the data that user is requesting data regularly.
  6. You can also use redis database as a persistent database. Here your data will be maintained and will not be deleted at all.

Background Processing

Don’t process all your data upfront following are the cases where we should use background processing

  1. Email sending
  2. Export large PDF, CSV
  3. Import data on daily or weekly basis from third party

I am sure that if you follow the above mentioned tips, you have done the possible basic to intermediate level optimization of your application. The application should be performing perfectly paced for the basic usage.

Happy coding!

· · · ·

Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.

We have expertise in the latest technologies including angular, react native, iOs, Android and more. Third Rock Techkno has developed smart, scalable and innovative solutions for clients across a host of industries.

Our team of dedicated developers combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.

Projects Completed till now.

Discover how we can help your business grow.

"Third Rock Techkno's work integrates complex frameworks and features to offer everything researchers need. They are open-minded and worked smoothly with the academic subject matter."

- Dr Daniel T. Michaels, NINS