The fuss over Spring’s speed
Lukáš Křečan may be no good at writing tabloid headlines, but he more than makes up for it with serious writing. In Is Spring Slow? he gets to the heart of the matter.
Spring just connects things and delegates all the work. I can think of only two areas where Spring could theoretically slow things down. The first is application startup, when the application context starts, proxies are created and dependencies are injected. In my experience the application context starts very quickly, even in large projects (if only Hibernate didn’t hold it up). The other area where Spring might theoretically slow the application down is AOP. But even there it delegates most of the work to the JRE or CGLIB. Almost everything else is handled by other products, such as Hibernate, the application server, JDBC or Quartz. So let’s say it again. Spring just glues the pieces of the puzzle together. If the puzzle is slow, the pieces themselves are to blame. The glue is just holding them together.
Lukáš is right, of course, but what I wanted to share was that there are extremists out there who actually measure how fast the glue is. William Louth wrote Benchmark Analysis: Guice vs Spring, which compares the speed of the Spring and Google Guice IoC containers. You could debate the value of the measurements, and of the whole benchmark for that matter. My view is that the benchmark has no relevance to a real deployment.
Related articles
Related CZ Podcast episodes
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio