Performance Optimization with Load Testing

Isaac Ochieng
Aug 8, 2019 · 5 min read

So you finally have your awesome web application up and running and all seems dandy. Your code is battle-tested, the unit tests worked like a charm and your Acceptance Testing was all but assured. Your website is up and running and users are trickling in slowly. Tens, hundreds, a thousand users login to your system and all of a sudden all hell breaks loose.

Whenever I ask anyone whether they will load test their web application, the answer is almost always this…

Do you even load test bro?

Performance Optimization is the process of making something, especially a computer system, work as effectively as possible. So in this context, it’s just more about making our applications run faster and in turn be able to handle a large number of users without any bottlenecks.

So what are some of the things that can cause these said bottlenecks on our web applications?

Client-Side Issues

  1. Using High-resolution images: I know it feels amazing when your website has amazingly crisp quality images but this impacts the load time of your website. The higher the resolution your image is, the higher the likelihood of the file to be large and in essence, your website taking a longer time to load.
  2. Importing unused js modules: The importing of modules that are not in use may heavily impact performance. TTI (Time to Interactivity) is heavily impacted because a lot of js files are being loaded.
  3. Loading scripts from<head>: Like the previous issue, you may have a lot of scripts that you’re using (which is fine), but, loading them on the <head> section of your website will slow a website. This is because when a parser finds these lines with scripts, it fetches said js files and executes them until they are finished then parse the <body> afterward and many scripts can lengthen the time before the <body> is parsed.

Server-Side Issues

  1. Poorly optimized queries to the database: I believe this to be the most urgent. A well-defined database with lots of relationships can make fetching data a bit complicated i.e. the need to use JOIN statements. By not specifying the fields that are in use, a JOIN statement can include the details of an entire table when only two or three fields are needed from the foreign table. This makes queries very slow and relaying this data to a client-facing app takes time.
  2. Using outdated language versions: It will always be likely that any update on a language’s version will be better performing than the previous one. i.e. from Node.js, they provide a link that shows the benchmark changes of the various versions and how performance improves per every new iteration. You can find this here.

To be able to identify these issues, load testing plays a huge role.

Load testing is defined as a type of software testing that determines a system’s performance under real-life load conditions.

Load testing improves performance bottlenecks, scalability, and stability of an application before it is available for production.

Why Load Test?

  • Load Testing gives us confidence in the system and its reliability and performance
  • Load Testing helps identify the bottlenecks in the system under heavy user stress scenarios before they happen in a production environment.
  • Load testing gives excellent protection against poor performance and accommodates complementary strategies for performance management and monitoring of a production environment.

Open Source Tools we can use

Locust is an open-source load testing tool that allows users to write Python code to test web applications.

Npm package that runs a load test on the selected HTTP or WebSockets URL.Locust running on localhost.

It is a fantastic lightweight testing tool that has been used widely across various large companies. i.e. by DICE, the game developer company of EA’s Battlefield games. No user interfaces are used to configure your tests, just pure Python code.


Loadtest is an npm package that runs a load test on the selected HTTP or WebSockets URL. Unlike Locust, loadtest allows us to only test a URL at a time. This is for quick load testing of a particular URL to see if meets a certain benchmark that is required before deploying to production. The documentation provided will allow you to create more test-cases for your particular needs.

So with load testing done and issues identified, there are a couple of ways you could improve the performance of your applications:

Client-Side Improvements

  1. Use of a CDN: A Content Delivery Network (CDN) is an interconnected system of computers on the internet that provides web content rapidly to numerous users by duplicating or caching the content on multiple servers and directing the content to users on proximity. CDNs reduce the load on the server and in turn, can improve the streaming quality of content on a website.
  2. Bundling and Minification: Bundling and minification improve load time by reducing the number of requests to the server and reducing the size of requested assets (CSS, JS).
  3. Image optimization: Yes, you have quality 4k resolution pictures but try and optimize them for your web application. Adobe Photoshop has a cool feature called “Save for Web” that makes your life way easier when optimizing photos. I’m sure there is a lot of software that can do the same function and a lot of tutorials online to help you achieve this.
  4. Removing duplicate code (JS and CSS): The more code you have, the more likely your application will be slower. Try and remove all the dead code that exists in your project. For this, you can do some research on tree shaking. Info on that you can find here.

Server-Side Improvements

  1. Caching: If you have a lot of data on your APIs that doesn’t change over a long period, caching works perfectly because there is no call to the database that is done. This increases load time exponentially. I have seen requests taking more than 2 seconds to load, take only 10 milliseconds to do so because of caching. Redis has been my go-to cache solution, have a look.
  2. SQL Optimization: From the base level when designing your database, you can optimize the database schema by:
    - Normalizing tables
    - Usage of optimal data types
    - Avoiding Null values
    - Avoiding too many columns
    More information on SQL optimization can be found here and here.

So that’s it! I hope this article has given you some insights on the importance of Load Testing and how we can optimize performance through it.

This is the last one I promise :)

If you have any questions or want to add some comments feel free to do so! Till next time!


Keeping It Simple

Isaac Ochieng

Written by

Node.js Developer. Gamer.



Keeping It Simple

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade