Microservices Load Testing: Top 5 Mistakes to Avoid Making Tests

What’s not to like about microservices (and microservices load testing)? Organizing application services into a set of semantically related resources represented as REST URLs makes sense, both in terms of development and usage. (See Figure 1.) And, making it so that a single two-pizza team is completely responsible for every aspect of the microservice — from design and implementation to deployment, testing and maintenance — creates companies that can turn on a dime. That’s the good news.

Microservices load testing - Micriservice architecture

Figure 1: Microservice architecture is discrete, flexible and well suited for development by small teams – Microservices Load Testing

The bad news is that when it comes to planning to load test microservices, we make mistakes. I know. I’ve made my share. The following are the top 5 mistakes I’ve made microservices load testing along with the lessons I’ve learned as a result. Hopefully the lessons I’ve Iearned will help you avoid making the mistakes I made.

1. Don’t Go Chasing 100% Testing All The Time, Pick the High Risk Services

Automated testing has become an important part of Continuous Delivery/Continuous Integration (CI/CD) process. Load testing is particularly important for microservices because the need to execute fast at scale. However, long running load tests can cause a bottleneck in the CI/CD process if performed to early in the software development lifecycle. So we have a paradox: Test too much too early and we slow the development process down. Test too late and we run the risk of paying the increased expense of fixing code late in the development cycle. What’s the solution?

The trick is to test high risk microservices at the start of the development cycle and leave less risky services for later. High risk microservices are the low hanging worthy of taking the time to load test. If a problem is discovered, the money saved fixing the problem early on outweighs the cost of the time it takes to run the test. It’s a net gain. Time intensive load testing on low risk microservices can take place later on in the software development lifecycle.

2. Don’t Waste Time Waiting Around For Fully Functional Dependencies, Use Service Virtualization

Dependencies can be the bane of software development. One team has code ready to go, but is held back from releasing it because another team has yet to deliver a dependency. This is a mistake. Code that’s ready to go, should go.

The way to address this type of delay is to use service virtualization. You can think of service virtualization as mocking out a service. You create a microservice that has the URLs you require. These URLs accept data according to the microservice specification and respond according to specification. However, the response is very limited in scope. For example, when you mock the endpoint, /customers/{id}, the response will always be:

"id": 123,
"first_name": "John",
"last_name": "Doe"

WHERE 123 is the id of the customer

Although the behavior is limited, it does serve the purpose required: to provide the consumable functionality of a dependency that is still under development.

There are a number of microservices load testing tools out there that make microservice virtualization an easy undertaking. Swagger Editor and Restito are two of many. You use these tools to specify the URLs that make up the microservice. Then behind the scenes, the tool implements the limited REST functionlality required, according to the specification.


3. Don’t Guess, Test to a Service Level Agreement

Testing to a service level agreement might seem like an obvious thing to do. But, many companies are organized in such that testing personnel and product management never know about each other, let alone interact in an informative way. This is a very un-Agile and it’s a mistake. Testers waste valuable resources imagining the operational conditions to meet. Product manager end up being frustrated when expectation are not met.

The easier way to avoid this problem altogether is to put products and testing into a room — real or virtual — and come up with a Service Level Agreement (SLA) by which product management expectations are well known and upon which good load tests can be designed and implemented. The SLA does not need to written in stone. Rather it should provide the flexibility to change as new needs are uncovered. The important thing is that the document to provides the concrete, common reference that sets the standards by which testing will be conducted and products will be accepted.

4. Don’t Pin All Your Hopes On One Runtime Environment, Use Many.

True story: A while back I was working on a microservice project that was deployed on one of the Big 3 Service providers (AWS/Azure/GC, I leave it to you to guess.). We dedicated our deployment to a Midwest US data center. During loading testing we discovered that the microservice took too long to execute. We couldn’t figure out why. The code ran great inhouse. So we did a no-brainer. We deployed the code to another region in Asia. Result? Everything was fine.

Did Asia have a better datacenter than Midwest US? We couldn’t really say. But we had the numbers to prove there was a difference.

So what’s the takeaway? Dedicating our deployment to one region was a mistake. We learned our lesson. Moving forward we ran our load tests in a variety of regions, particularly when we were testing for regression.

5. Don’t Assume Request/Response Is All There Is To Measure.

While it’s true that load testing the performance of the requests and responses associated with a microservice is important, there’s more to be considered. Behind the scenes there can be a lot more activity that needs to be observed and measured — reading and writing to message queues and memory caches for example. Thus, when implementing microservices load testing, it’s important to have monitors in place to observe the behavior of all the components associate with the microserve. There are reasons for a slow response from a microservice and they need to be known. Typically a good Application Performance Management or API Management solution provides the system monitors required to get the information associated with a poorly performing load test.

Also, keep in mind that for full stack applications, a microsservice that performs well under direct load test, might have trouble when it comes to User Experience (UX) testing. For example, a small alteration in a data structure might have unintentional side effects in UI behavior. For those companies that publish microservices as components of a larger application, testing performance at the UI level will have benefit.
The important thing to remember is that many times, in order to get a good performance profile, online load testing needs to go beyond simply measuring response times for REST calls to a single microservice.

Putting It All Together

There’s more to microservices load testing than taxing the request capacity of set of URLs. An efficient load test plan will use service virtualization to get more code under test faster. Also an efficient load test will identify the high risk services to test early in the development cycle and leave more time consuming tests for later on. Testers and product managers will agree upon a common Service Level Agreement that be the basis for load testing analysis. Tests will be conducted in a variety of runtime environments. Lastly, a good test plan will use Application Performance Management, API Management solutions in conjunction with comprehensive load testing tools and load testing software to go beyond simply measuring the response time of a microservice’s URLs.

Avoiding the 5 mistakes I’ve made above will go a long way to creating effective load tests that measure a broad scope of microservice behavior. Broad, comprehensive load testing implemented throughout the software development lifecycle is critical for making quality microservices that perform at scale.

More About Microservices Load Testing?

Discover more load testing and performance testing content on the Neotys Resources pages, or download the latest version of NeoLoad and start testing today.

Keep Me Informed