How can Service Virtualization help you Shift-Left?

Part 1 of 2:

Modern applications, primarily those that rely on microservices, rarely operate in isolation. They are dependent on third-party services, databases, and APIs. But, when it comes down to performance testing these applications early, mostly they are not available, not built, costly, or unstable.

This is where service virtualization steps in.

In simple words, service virtualization means creating realistic stand-ins for your dependencies so that your application thinks it’s talking to the real thing. You can control their behavior and also test edge cases.

But Why Service Virtualization?

  • Test early: There’s no need to wait for all downstream systems to be live.
  • Full control: Simulate latency, throttling, and error rates on demand.
  • Repeatability: Run the same conditions every time for consistent results.
  • Cost saving: Avoid charges for external API usage during performance tests.

Think of it like a movie set where you don’t need the real city to shoot your scene; you just need something realistic enough for the camera (or in our case, the application).

Our Demo Intention

This is a two-part series. Part 1 demonstrates how you can set up service virtualization, and Part 2 demonstrates how to performance test those mock services. So, let’s dive in.

Tools we used

  1. Windows 11 + Docker Desktop (WSL) + WSL2 – to run our virtualized containers
  2. WireMock – for HTTP based virtualization
  3. JMeter – for generating performance load
  4. Powershell / curl – for quick endpoint testing

Step-by-Step Demo Setup

1. Prepare Windows for Docker

  • Enable virtualization in BIOS (check Task Manager → CPU → Virtualization: Enabled)
  • Install WSL
wsl.exe --list --online
wsl.exe --install Ubuntu-22.04
  • Install Docker Desktop (enable WSL 2 based engine)

2. Clone the POC Project

https://github.com/thescalableguy/wiremock-poc

3. Spin Up the Virtual Services

  • In Powershell, navigate to the folder where you have cloned the project
cd /path/to/project
docker compose up -d

4. Test the Endpoints

Inventory Services:

Invoke-RestMethod "http://localhost:8081/inventory?sku=ABC123"

Pricing Service

Invoke-RestMethod "http://localhost:8081/pricing?sku=ABC123"

If you’ve made it this far, I will wrap up Part 1 of our demonstration here. As promised, in the next and final part, I will walk you through performance testing these services and exploring some extreme scenarios.

Key Takeaways

  • Service virtualization lets you test earlier and smarter.
  • You can simulate realistic downstream behavior without waiting.
  • It’s a powerful tool for performance, integration, and resilience testing.

Leave a Reply

Discover more from the scalable guy

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from the scalable guy

Subscribe now to keep reading and get access to the full archive.

Continue reading