Reputation: 73
I am developing an API using spring and I have some doubts.
Imagine I have a @Controller
which one of it's endpoints takes 2 minutes to process a response.
If I do multiple petitions with different users at the same time to that specific endpoint.
How does Spring manage it? Is it concurrent?
In theory the controllers are Singleton, therefore the controller wouldn't be able to answer the next petition before he ends the last one.
Thanks
Upvotes: 0
Views: 40
Reputation: 723
The controllers are Singleton for sure, but they can be accessed concurrently. So many user requests can be handled in parallel by the same controller. That is why your controller should be stateless, that is, you should not store user data in the controller attributes.
Upvotes: 2