Skip to content

Load-Testing

How to load test a Rest API

REST APIs are becoming widely popular. Our own application is designed with a REST API. What does it mean? It's a software architecture where a client (the Web Browser) talks to a server (an HTTP server in our case) mostly using the HTTP protocol.

REST services used to communicate using an XML based protocol called SOAP. SOAP is still used by big companies in legacy REST services. Nowadays, REST APIs are mostly communicating using the JSON format. JSON is human readable, like XML, but simpler. It lacks all the security layers SOAP can offer, but most of the web application don't require them.

In this article, we explain how to easily run thousands of concurrent users on your REST Api using OctoPerf.

Response time is critical for E-Commerce

Online E-commerce business is growing very quickly. From 2007 to 2015, the US Online retail sales have grown by 38%. And the market is still growing rapidly year over year.

Online E-commerce Growth

In this context, being able to follow the business growth is critical. The goal of any online retailer is to increase the number of visitors, and thus increase the number of orders. But, bringing more people on an online shop can quickly become a pain if the shop is not prepared for it.

Imagine you have an e-commerce. The local TV makes an interview of you, a successful entrepreneur. Many people will see you, and want to visit your shop to see what you are selling. This is where the nightmare begins. The opportunity to make more sales is compromised by the absolute slowness of the website. The servers are overloaded.

Recording HTTP traffic with Fiddler

Fiddler is an HTTP proxy primarly designed to debug HTTP requests. It allows to capture HTTP traffic and export it in different format. OctoPerf supports importing HAR (Http Archive v1.2), which is precisely what Fiddler can do. In this post, you will learn how to record your web or mobile app with Fiddler, and then run a load test from the Cloud with OctoPerf.

We are going to use FiddlerCap, which is a very simple and powerful.

Why recording

Recording an HTTP app is the best way to run realistic load tests. You are guaranteed to capture the real HTTP traffic between a customer and your web app. It's also quicker to record the traffic instead of creating it manually from scratch.

Recording HTTP traffic with JMeter

JMeter is an open-source load testing tool. See related posts if you want more information about JMeter. JMeter allows to record HTTP traffic with its built-in HTTP(S) Test Script Recorder. OctoPerf natively supports importing JMeter recordings.

Installation

First, you need to install JMeter on your computer:

  • Get JMeter from JMeter Download Page,
  • Decompress the archive,
  • Run JMETER_HOME/bin/jmeter executable (extension depends on your OS).

JMeter GUI should appear. JMeter is a Java program, it requires a Java JRE. Install one if you don't have any.

JMeter vs Gatling Tool

I think you'll agree when I say:

It's REALLY hard to decide whenever JMeter or Gatling Tool should be used.

You're probably wondering:

  • How does JMeter to Gatling Tool compare?
  • Which tool has best documentation? Performances? Script Maintainability?
  • Should I use JMeter or Gatling? Or maybe both?

Well, it turns out you can gain significant insight on JMeter and Gatling differences in just 5 minutes reading!

Following up our article about why we chose JMeter to build OctoPerf, our Cloud Load Testing Platform, this post compares JMeter and Gatling Tool on many different fields:

  • Project History: which tools is improved and maintained more actively,
  • Features: which of the two has the most features,
  • Setup: how each tool can be installed,
  • Documentation: which tool does have the most complete documentation,
  • Scripting: compares how to design scripts with both tool,
  • Performances: is JMeter faster than Gatling? Which is the most efficient tool,
  • and even more!

Ready for some action? Let's go!