Expected 404s and Gatling

Published: November 1, 2019


For many websites, for one reason or another (bots?), a not insignificant amount of traffic winds up hitting a 404 page. When load testing a website like this it is important that this traffic is represented for an accurate simulation.

With Gatling, by default a 404 response code is interpreted as a “KO”. But in this case the 404 is expected and should not be represented as a failure in Gatling’s reports.

We can tell Gatling the 404 status is expected by adding .check(status.is(404)) to the request.

Here’s a full example:

val scn = scenario("Scenario 1")

Max Chadwick Hi, I'm Max!

I'm a software developer who mainly works in PHP, but loves dabbling in other languages like Go and Ruby. Technical topics that interest me are monitoring, security and performance. I'm also a stickler for good documentation and clear technical writing.

During the day I lead a team of developers and solve challenging technical problems at Something Digital where I mainly work with the Magento platform. I've also spoken at a number of events.

In my spare time I blog about tech, work on open source and participate in bug bounty programs.

If you'd like to get in contact, you can find me on Twitter and LinkedIn.