Memory wasted by Spring Boot PetClinic application
How much memory are you wasting with duplicate strings? In this article, Ram Lakshmanan goes through a Spring Boot PetClinic application and notes how much memory it wastes. If you can reduce the number of objects that are created to service new incoming requests, your response time will get a lot better.
One of the widely wasted resources in the world today is memory. Due to inefficient programming, a surprising (sometimes ‘shocking’) amount of memory is wasted. We see this pattern repeated in several enterprise applications. To prove this case, we conducted a small study. We analyzed the famous Spring Boot PetClinic application to see how much memory it is wasting. This application has been designed by the community to show how the Spring application framework can be used to build simple but powerful database-oriented applications.
- Spring Boot 2.1.4.RELEASE
- Java SDK 1.8
- Tomcat 8.5.20
- MySQL 5.7.26 with MySQL connector/J 8.0.15
We used Apache JMeter, a popular open-source load testing tool, to conduct our stress test. We executed the load test for 30 minutes with the below settings:
- Number of Threads (Users) – 1000 (Number of users connects to the target)
- Ramp-Up Period (in seconds) – 10. The time frame for all requests to start. As per our configuration at every 0.01 second, 1 new thread will start i.e 100 threads/second.
- Loop Count – Forever. These 1000 threads perform a test iterations back-to-back.
- Duration (seconds) – 1800. After ramp-up 1000 threads run continuously for 1800 seconds.
We exercised the following scenarios in our load test:
- Add a new pet owner to the system.
- View information pertaining to a pet owner.
- Add a new pet to a system.
- View information pertaining to a pet.
- Add information pertaining to a visit to a pet’s visitation history.
- Update the information pertaining to a pet.
- Update the information pertaining to a pet owner.
- View owner information by searching his name.
- View information of all owners.