Are Spring MVC Controllers Singletons?

Spring controllers are singletons (there is just one instance of each controller per web application) just like servlets. Typically there is no point in changing this behaviour (if it’s even possible). See Regarding thread safety of servlet for common pitfalls, also applying to controllers.

If your application is clustered do as much as you can to avoid state. State in controllers will require synchronization to avoid threading issues. Also you’ll probably replicate that state across servers – very expensive and troublesome.

Leave a Comment