---
title: Improving the performance of the Spring-Petclinic sample application (part 3 of 5)
description: "This is part 3 of our 5-part series on improving the performance of the\nSpring-petclinic application. Here are part 1\n[https://test-ippon.ghost.io/improving-the-performance-of-the-spring-petclinic-sample-application-part-1-of-5/] \nand part 2\n[https://test-ippon.ghost.io/improving-the-performance-of-the-spring-petclinic-sample-application-part-2-of-5/]\n.\n\nYesterday we managed to make the application handle 5000 users, with an average\nperformance of 867 req/"
image: https://blog.ippon.tech/hubfs/Imported_Blog_Media/ippon-bkr-Jan-18-2024-06-00-39-1597-PM.png
---

[Skip to main content](https://blog.ippon.tech/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5#main)

[![IpponLogoKleinBlue](https://blog.ippon.tech/hs-fs/hubfs/IpponLogoKleinBlue.png?width=219&height=64&name=IpponLogoKleinBlue.png) ![IpponLogoKleinBlue](https://blog.ippon.tech/hs-fs/hubfs/IpponLogoKleinBlue.png?width=219&height=64&name=IpponLogoKleinBlue.png) ![IpponLogoKleinBlue](https://blog.ippon.tech/hs-fs/hubfs/IpponLogoKleinBlue.png?width=168&height=49&name=IpponLogoKleinBlue.png) ![IpponLogoKleinBlue](https://blog.ippon.tech/hs-fs/hubfs/IpponLogoKleinBlue.png?width=168&height=49&name=IpponLogoKleinBlue.png)](https://ipponusa.com/)

- [Home](https://ipponusa.com)
- [Show submenu for About About](https://ipponusa.com/about-us) 
    - [Who We Are](https://ipponusa.com/who-we-are)
    - [Careers](https://ipponusa.com/careers)
    - [Show submenu for Our Partners Our Partners](https://ipponusa.com/our-partners/) 
          - [AWS](https://ipponusa.com/our-partners/aws/)
          - [Snowflake](https://ipponusa.com/our-partners/snowflake/)
          - [Databricks](https://ipponusa.com/our-partners/databricks/)
          - [Microsoft](https://ipponusa.com/our-partners/microsoft/)
- [Show submenu for Services Services](https://ipponusa.com/services) 
    - [Snowflake](https://ipponusa.com/service/snowflake-concierge/)
    - [Artificial Intelligence](https://ipponusa.com/service/artificial-intelligence/)
    - [Data & Analytics](https://ipponusa.com/service/data-analytics/)
    - [Cloud Strategy](https://ipponusa.com/service/cloud-strategy/)
    - [Platform Modernization](https://ipponusa.com/service/platform-moderization/)
    - [Product Innovation](https://ipponusa.com/service/product-innovation/)
    - [Operating Model](https://ipponusa.com/service/operating-model/)
- [Blogs](https://blog.ippon.tech/)
- [Success Stories](https://ipponusa.com/success-stories/)
- [Show submenu for Resources Resources](https://ipponusa.com/resources/) 
    - [eBooks](https://ipponusa.com/ebooks/)
    - [The Data Pour](https://info.ippon.tech/the-data-pour)
    - [Videos & Webinars](https://info.ippon.tech/videos-and-webinars)
    - [Media Center](https://ipponusa.com/media-center/)

Search

Open main navigation

Close main navigation

- [Home](https://ipponusa.com)
- Show submenu for About About 
  
    - About
    - [About](https://ipponusa.com/about-us)
    - [Who We Are](https://ipponusa.com/who-we-are)
    - [Careers](https://ipponusa.com/careers)
    - Show submenu for Our Partners Our Partners 
      
          - Our Partners
          - [Our Partners](https://ipponusa.com/our-partners/)
          - [AWS](https://ipponusa.com/our-partners/aws/)
          - [Snowflake](https://ipponusa.com/our-partners/snowflake/)
          - [Databricks](https://ipponusa.com/our-partners/databricks/)
          - [Microsoft](https://ipponusa.com/our-partners/microsoft/)
- Show submenu for Services Services 
  
    - Services
    - [Services](https://ipponusa.com/services)
    - [Snowflake](https://ipponusa.com/service/snowflake-concierge/)
    - [Artificial Intelligence](https://ipponusa.com/service/artificial-intelligence/)
    - [Data & Analytics](https://ipponusa.com/service/data-analytics/)
    - [Cloud Strategy](https://ipponusa.com/service/cloud-strategy/)
    - [Platform Modernization](https://ipponusa.com/service/platform-moderization/)
    - [Product Innovation](https://ipponusa.com/service/product-innovation/)
    - [Operating Model](https://ipponusa.com/service/operating-model/)
- [Blogs](https://blog.ippon.tech/)
- [Success Stories](https://ipponusa.com/success-stories/)
- Show submenu for Resources Resources 
  
    - Resources
    - [Resources](https://ipponusa.com/resources/)
    - [eBooks](https://ipponusa.com/ebooks/)
    - [The Data Pour](https://info.ippon.tech/the-data-pour)
    - [Videos & Webinars](https://info.ippon.tech/videos-and-webinars)
    - [Media Center](https://ipponusa.com/media-center/)
- Search
- [Contact Us](https://ipponusa.com/contact/)

[Contact Us](https://ipponusa.com/contact/)

# Improving the performance of the Spring-Petclinic sample application (part 3 of 5)

![Julien Dubois](https://app.hubspot.com/settings/avatar/d41d8cd98f00b204e9800998ecf8427e)

 by [Julien Dubois](https://blog.ippon.tech/author/julien-dubois)

March 13, 2013

![Improving the performance of the Spring-Petclinic sample application (part 3 of 5)](https://blog.ippon.tech/hubfs/Imported_Blog_Media/ippon-bkr-Jan-18-2024-06-00-39-1597-PM.png)

[Performance](https://blog.ippon.tech/tag/performance/) [Spring](https://blog.ippon.tech/tag/spring/)

 

Mar 13, 2013

 

This is part 3 of our 5-part series on improving the performance of the Spring-petclinic application. Here are [part 1](https://test-ippon.ghost.io/improving-the-performance-of-the-spring-petclinic-sample-application-part-1-of-5/?ref=blog.ippon.tech) and [part 2](https://test-ippon.ghost.io/improving-the-performance-of-the-spring-petclinic-sample-application-part-2-of-5/?ref=blog.ippon.tech).

Yesterday we managed to make the application handle 5000 users, with an average performance of 867 req/sec. Let’s see if we can improve this today.

## Removing the JVM locks

Running the tests from part 2 showed us that some requests are taking a lot longer than the others, in fact our application does not answer requests fairly to all users.

As this is rather strange, we run up YourKit again, this time to check if we have some locked threads in the JVM:

![](https://blog.ippon.tech/hubfs/Imported_Blog_Media/screenshot_3-1.png)

This YourKit screenshot shows a profiling session, where each time a thread is locked it becomes red.

It seems we have a few locks! This explains why some requests are really slow, they are getting locked by the JVM.

YourKit also shows us 3 main culprits for those locks, which we are going to remove one at a time.

## Removing Commons DBCP

The first cause of those locks is our database connection pool, Commons DBCP, which is well-known for doing a lot of synchronization.

Let’s switch to tomcat-jdbc, which is the new Tomcat connection pool :

[\[Source code\]](https://github.com/jdubois/spring-petclinic/commit/bb1b399771fe6748294ec410136aebbdbb327d3f?ref=blog.ippon.tech)

We have limited the number of connections to 8, which is a very small number, for two reasons:

- This is the default configuration of Commons DBCP, and we wanted to have a comparable configuration
- For this test, everything runs on the same machine, so we can’t have too many concurrent connections, or the performance will in fact decrease

On a real production system, it is very likely that a number between 30 and 100 would be a better configuration.

Testing the application again, **we now achieve 910 req/sec**.

## Removing Webjars

[Webjars](http://www.webjars.org/?ref=blog.ippon.tech) is a library that is used to manage client-side libraries like JQuery or Twitter Bootstrap.

We have included a request to get JQuery in the stress test, in fact we expected this to cause some trouble: Webjars is using the same mechanism as Richfaces to provide static resources, and we already had that exact same issue with Richfaces (by the way, many other Web frameworks, like Play!, are doing the same). Indeed, the JVM is doing a big lock each time someone tries to load a Web library.

We have experienced this being an issue at a client site: we are only testing here with one Web library, but if we were using all the libraries from the application, things would be much worse.

For this particular client:

- We had a few hundred users, not enough to bother setting up a specific system (like a CDN) to handle static resources
- Every user was using the application through HTTPS, which minimized browser caching

After discussing with James Ward, the author of Webjars, we have the following best practices for using Webjars:

- Use a caching HTTP Server as a front-end (or a CDN for a bigger Web application)
- Use a framework that automatically caches Web resources. Unfortunately Spring doesn’t do it by default, But it shouldn’t be too hard to add [using an interceptor](http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/mvc/WebContentInterceptor.html?ref=blog.ippon.tech)

We have decided to simulate that we have a specific caching mechanism (of course, another solution is to remove Webjars and manage your Web libraries manually):

[\[Source code\]](https://github.com/jdubois/spring-petclinic/commit/2b3ed81a9b294587573cf0bd43402264355dd15b?ref=blog.ippon.tech)

For our next steps, we have now disabled the “JS” step in our JMeter test, and have enabled the “JS no webjar” step instead. This will make our stress test use the JQuery script that is served directly by the server, without using Webjars.

So let’s get down to the results: **we are now at 942 req/sec**.

## Removing the monitoring aspect

This last issue was created on purpose: we have a small lock in the aspect which is provided to monitor the application with JMX.

It’s in fact a very good idea, but it has a negative impact on performance. Let’s remove it:

[\[Source code\]](https://github.com/jdubois/spring-petclinic/commit/197888fef0ad5066006f817c801c99f57e44103d?ref=blog.ippon.tech)

**We now reach 959 req/sec**.

## Conclusion of part 3

We have used our profiler to quickly see that we had some JVM locks on the application. We have removed each of them, and saw each time an increase in the performance of the application.

Using YourKit again, we don’t see any JVM locks any more on the application (no red threads anymore!):

![](https://blog.ippon.tech/hubfs/Imported_Blog_Media/screenshot_4-1.png)

Our application **went up from 867 req/sec to 959 req/sec**. This is of course a better result, and it would probably be even better on a real production server, which has more cores and threads than the Macbook we are using for the tests.

On part 4, we will test if we can do better with JPA than with JDBC.

\[edit\]

You can find the other episodes of this series here : [part 1](http://blog.ippon.fr/?p=7496&ref=blog.ippon.tech), [part 2](http://blog.ippon.fr/?p=7500&ref=blog.ippon.tech), [part 4](http://blog.ippon.fr/?p=7520&ref=blog.ippon.tech) and [part 5](http://blog.ippon.fr/?p=7527&ref=blog.ippon.tech).

## Related Articles

##### [![Deep Dive Webflux](https://blog.ippon.tech/hs-fs/hubfs/1-2.png?width=520&height=294&name=1-2.png) Spring • July 11, 2024 Deep Dive Webflux 4 min read](https://blog.ippon.tech/deep-dive-webflux)

##### [![Getting Your Application Started With WebFlux](https://blog.ippon.tech/hs-fs/hubfs/Webflux%20image%20(1).png?width=520&height=294&name=Webflux%20image%20(1).png) Spring • May 7, 2024 Getting Your Application Started With WebFlux 6 min read](https://blog.ippon.tech/getting-your-application-started-with-webflux)

##### [![Webflux - Starting your journey](https://blog.ippon.tech/hs-fs/hubfs/Untitled%20design.png?width=520&height=294&name=Untitled%20design.png) Ippon • March 19, 2024 Webflux - Starting your journey 6 min read](https://blog.ippon.tech/webflux-starting-your-journey)

### Comments

### Subscribe to Our Blog!

Stay informed with the latest insights and updates by signing up for our weekly blog newsletter – delivered straight to your inbox!

[Back to blog homepage »](https://blog.ippon.tech/)

![IpponLogoKleinBlue](https://blog.ippon.tech/hs-fs/hubfs/IpponLogoKleinBlue.png?width=247&height=73&name=IpponLogoKleinBlue.png "IpponLogoKleinBlue")

Ippon is a consulting and expertise firm, who is convinced that technology is a source of progress for society. We help our clients leverage their digital assets to design an appropriate strategy and deploy their transformation roadmap at scale.

#### Navigation

- [Home](https://ipponusa.com/)
- [About](https://ipponusa.com/about-us/)
- [Services](https://ipponusa.com/services/)
- [Blogs](https://blog.ippon.tech/?__hstc=223043268.1036d82247623b329dfefe4e92697801.1714729179243.1714729179243.1714729179243.1&__hssc=223043268.2.1714729179244&__hsfp=803678701)
- [eBooks](https://ipponusa.com/ebooks/)
- [The Data Pour](https://info.ippon.tech/the-data-pour?__hstc=223043268.1036d82247623b329dfefe4e92697801.1714729179243.1714729179243.1714729179243.1&__hssc=223043268.2.1714729179244&__hsfp=803678701)

[Contact Us](https://ipponusa.com/contact/)

[Join Us](https://ipponusa.com/careers/)

#### Services

- [Data & Analytics](https://ipponusa.com/service/data-analytics/)
- [Cloud Strategy](https://ipponusa.com/service/cloud-strategy/)
- [Artificial Intelligence](https://ipponusa.com/service/artificial-intelligence/)
- [Operating Model](https://ipponusa.com/service/operating-model/)
- [Platform Modernization](https://ipponusa.com/service/platform-moderization/)
- [Product Innovation](https://ipponusa.com/service/product-innovation/)

#### Ippon International

- [France](https://fr.ippon.tech/?__hstc=223043268.1036d82247623b329dfefe4e92697801.1714729179243.1714729179243.1714729179243.1&__hssc=223043268.2.1714729179244&__hsfp=803678701)
- [Australia](https://au.ippon.tech/?__hstc=223043268.1036d82247623b329dfefe4e92697801.1714729179243.1714729179243.1714729179243.1&__hssc=223043268.2.1714729179244&__hsfp=803678701)

- #### Contact
- Ippon Technologies  
  [3431 West Leigh Street Richmond, VA 23230, USA](https://maps.app.goo.gl/RySm6SAwZnsxeiLz9)
- [(844) 477- 6687](tel:8444776687)
- [Sales@ipponusa.com](mailto:Sales@ipponusa.com)

<https://www.facebook.com/IpponUSA/> <https://www.youtube.com/c/ipponusa> <https://www.linkedin.com/company/ippon-technology>

©Copyright 2024 Ippon USA. All Rights Reserved.   |   [Terms and Conditions](https://ipponusa.com/privacy-policy/)   |   [Privacy Policy](https://ipponusa.com/privacy-policy/)   |   [Website by Skol Marketing](https://skolmarketing.com/)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Julien Dubois",
    "url" : "https://blog.ippon.tech/author/julien-dubois"
  },
  "dateModified" : "2024-01-29T17:05:27.046Z",
  "datePublished" : "2013-03-13T14:12:00.000Z",
  "headline" : "Improving the performance of the Spring-Petclinic sample application (part 3 of 5)",
  "image" : [ "https://blog.ippon.tech/hubfs/Imported_Blog_Media/ippon-bkr-Jan-18-2024-06-00-39-1597-PM.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.ippon.tech/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.ippon.tech/hubfs/logo_SVG.svg"
    },
    "name" : "Ippon Technologies"
  }
}
```