Observability Done Right: Best Practices and Anti-Patterns for Effective System Monitoring

Image
  WHAT Observability is a concept that refers to the ability to gain insights into the behavior and performance of complex systems. In the context of software engineering, observability involves the collection, analysis, and visualization of data from software applications, infrastructure, and other components of a system. In the animal kingdom, observability plays a critical role in survival, allowing animals to monitor their surroundings, detect threats, and find food. Dolphins use echolocation to observe their surroundings. They emit high-frequency sounds that bounce off objects, allowing them to create a 3D map of their environment. Thanks for reading Knowledge Cafe! Subscribe for free to receive new posts and support my work. Subscribed WHY In today's era, architectures are becoming increasingly large, complex, and fast-paced due to the faster development and deployment of software by distributed teams with the help of DevOps, continuous delivery, and agile development methodo...

API Benchmarking with Gatling

 


What and Why Performance Measurement:

The downtime of a mission-critical application can be very costly in recent time. It can lead to customer loss or financial loss. In today's world most of the web applications are built using APIs. APIs should be functionally correct, as well as available, fast, secure and reliable. It is very important to gather the data about API performance periodically. This will give us information about health and hygiene of our application. It doesn’t matter how beautiful your front end applications are if the API data sources take several seconds to respond or even worse if API performance is not consistent. API Performance matters very much in a world of microservices, which means the source of what a client application shows is probably being aggregated from multiple APIs behind the scenes.

How to Measure API Performance:

There are many tools available for performance measurement. This page list open source tools for performance measurement.

https://github.com/denji/awesome-http-benchmark

In this article we will focus on GatlingGatling is designed for continuous load testing and integrates with your development pipeline. Gatling includes a web recorder and colorful reports. Gatling’s architecture is asynchronous, which means it is very easy to create thousands of virtual users rather than managing dedicated threads

In this article, I am going to use following

1. Intellij Idea with JDK8

2. Test App with random delay in get endpoint. (https://github.com/amithimani/mycabdemo)

3. Test Project (not mandatory but good to have) (https://github.com/amithimani/gatling)

First Lets create Test project using maven archetype. 

mvn archetype:generate

Then you will see prompt like below, enter latest version available and provide details like groupIdartifactIdversion and package name.




Once done, We can open this project in IDE. 

There are two ways to define the scenarios

1. Using Gatling UI

2. Using Gatling DSL: We will focus on Gatling DSL in this article. 

We will create test scenario in src/test/scala folder as below scala class

  
package basic;
import io.gatling.http.Predef._
import io.gatling.core.Predef._

class GatlingTest extends Simulation {
  val httpConf = http
    .baseUrl("http://localhost:8080/v1/drivers?onlineStatus=ONLINE") //Application URL
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")

  val scn = scenario("GetDriverList")
    .exec(http("Get Drivers Request")
      .get(""))
    .pause(1)

  setUp(
    scn.inject(atOnceUsers(100)) //Number of concurrent users 
  ).protocols(httpConf)
}

An interesting thing about Gatling is that you can create your tests using your favorite IDE environment as well as run the test using IDE or it can be part of Jenkins pipeline. 

This test will generate beautiful html report. Here are some sample screenshot of report.





Popular posts from this blog

Chain of responsibility using Spring @Autowired List

Iterate Through a HashMap

Under the Hood: Understanding the Gossip Protocol in Apache Cassandra