
Choosing the appropriate Amazon EC2 instance type is an important task, but it can be frustrating to navigate the many options available and understand what kind of performance to expect. One common pitfall is to assume similar specs have the same performance characteristics across instance classes. We recently ran into this problem at Credera when changing instance types for one of our own internal applications running on AWS.
Background
The application in question is composed of multiple Java Spring Boot microservices sharing the same t2.large EC2 instance. Over time, services were added until we were using close to 100% of the 8 GB of RAM available on our instance. To remedy this, we made the decision to move up to a memory-optimized r4.large instance. It had two vCPUs just like the t2.large and almost double the memory at 15.25 GB.
Shortly after, we noticed that it was taking close to twice the amount of time for all our services to start up during deployments. This pointed to a CPU issue, but that didn’t seem to make sense. An r4.large instance has the same number of vCPUs as a t2.large, and the underlying Intel Xeon processor is roughly the same in terms of raw performance. So what could cause the difference?
A Surprising Difference
For a while, we were stumped as to what could be causing the slowdown. It wasn’t until I read the documentation on AWS’s new CPU option customization capabilities that it clicked: Not all vCPUs are made the same.
It turns out there is an important piece of information on AWS’s instance types page that can be easy to overlook because it is just a footnote at the bottom of a very large table:
