Get started today
Replay past traffic, gain confidence in optimizations, and elevate performance.

Organizations are starting to realize that simply writing tests to generate traffic is simply not good enough. Rather, production traffic replication is now necessary, where you record traffic from your production environment and then replay it in your development environment.

To match the modern principles of this testing methodology, it makes sense to also utilize modern infrastructure, like Kubernetes.

Some benefits of using Kubernetes for production traffic replication are the ability to:

  • Use sidecars as proxies
  • Reuse existing infrastructure
  • Utilize autoscaling rules.

Additionally, load generators are ephemeral.

These reasons—and a few more besides—will be covered later in this post, but let’s first take a deeper look at what production traffic replication is.

What is Production Traffic Replication?

Production traffic replay is the act of recording traffic from your production environment and replaying it in another environment. With this, you are getting some distinct advantages over regular traffic generation:

  • You’re getting more realistic tests;
  • You don’t have to create the tests yourself;
  • You’re able to discover ways in which your users are utilizing your application—ways that you perhaps didn’t expect.

At a high level, it’s that simple. However, as with anything in the software world, there are always ways to optimize and improve. For example, a proper tool won’t just record the incoming traffic and replay it one-to-one.

In some cases you need to sanitize the input before sending it to your development service, like changing timestamps, modifying authentication headers, changing IDs, etc. In those cases it’s important to use a tool that can help do that dynamically.

Besides that, it’s important to consider the outgoing requests from your service, just as much as the incoming. Imagine that you’re using traffic replication to perform a load test. In that case, it’s likely you won’t want to be load testing your third-party APIs, meaning you will have to mock those APIs. Here it’s helpful to have a tool that does it automatically.

Benefits of Using Kubernetes

There’s a difference between production traffic replication, and good production traffic replication. Technically, you can use wireshark to capture traffic and then replay it using a bash script. However, most engineers will likely agree that it’s not the best procedure.

There are already tools out that there that is able to capture production traffic like GoReplay, however that then has the downside of being difficult to manage in Kubernetes.

And, it’s of course important to use the best and most optimal tool for the job, and while your mileage may vary, Kubernetes is for many the best tool for traffic replication. Let’s dive deeper into what these advantages are.

To Take Advantage of Sidecars

One of the biggest advantages of Kubernetes is the way that sidecars can be implemented as proxies. Without having to manage extra infrastructure, and more importantly without having to modify your code or configurations, you can make some changes to how your applications behave.

With a sidecar added to your services you can easily have all traffic—incoming and outgoing—recorded and saved, without interfering with your service. If you’re using a tool like Speedscale that installs an Operator into your cluster, you won’t even have to worry about managing the sidecars.

In essence, this creates a frictionless way for you to record all your traffic. Sidecars are changing the game.

To Quickly Generate Load

Traffic replication is of course not only about recording traffic; it’s also about replaying it. There are many ways that you can generate traffic:

  • Use Postman;
  • Create bash scripts;
  • Use load-testing tools like JMeter or GoReplay.

These options all share one common downside: they are run locally. By using Kubernetes you can utilize its flexible nature to quickly spin up new Pods to generate traffic. Not only that, you can use the highly scalable capabilities to perform heavy load and performance tests.

To Create Automatic Mocks

We’ve already mentioned how sidecars are tremendously helpful in terms of recording traffic, but they also help a lot with the outgoing requests, by automatically creating mocks.

It’s very common for engineers to focus on creating mock services by either coding it into the application directly via test frameworks, or by spinning up new services. However, with sidecars, you don’t even have to create a new service.

With the sidecar acting as a proxy for outgoing traffic as well, it can simply intercept the traffic, prevent it from leaving the Pod, and instead respond to your service with the recorded response from production.

Not only does this greatly optimize the efficiency of your tests, but you’re also reducing resource costs. The fact that mocks are automatically created will save you a lot of time, as there are otherwise many considerations to be had.

To Reuse Existing Infrastructure

For one-off traffic replays, you may want to run it from your local PC. However, for more serious use-cases, you’ll want to have it running as part of your infrastructure. Given that Kubernetes is able to run any application that can be dockerized, you can spin up your load generators as Pods.

Reusing your existing infrastructure like this can be a great way to save both overall cost and operational overheads.

In the image below you can see how easy a tool like Speedscale makes it to use your already existing Kubernetes resources.

Speedscale "How to Replay"

To Reuse Existing Deployment Methods

On top of being able to reuse your existing infrastructure, using Kubernetes will also let you reuse your existing deployment methods. Whether you’re using Helm, Kustomize, or something entirely different, a Pod is a Pod.

Start Using Production Traffic Replication Today

Production traffic replication can be implemented in a variety of ways, but to ensure the most optimal workflow you should be using Kubernetes. The use of sidecars combined with the flexible and scalable nature of Kubernetes lets you get started quickly.

At this point it’s a matter of choosing the right tool to take advantage of these options. Speedscale works exclusively with Kubernetes—try it right now with an interactive demo.

Ensure performance of your Kubernetes apps at scale

Auto generate load tests, environments, and data with sanitized user traffic—and reduce manual effort by 80%
Start your free 30-day trial today