Search code examples
grailsserviceconcurrencyblockingcontrollers

Thread Pooling in Grails Controllers and Services


I'm wondering how controllers and services are implemented in Grails. In particular I would like to know, whether and how it maintains a thread pool for both controllers and services.

Assuming following scenario:

I have a Grails controller that calls a service that does a blocking call to a external system.

Would I need to take care of maintaining a thread pool in the service (or even the controllers), so that when I have multiple user concurrently access my application, the application does not block because of a call in one service?


Solution

  • You don't need to make anything specific, on Grails side, each request executed in own thread, concurently.

    From official docs: "By default access to service methods is not synchronised, so nothing prevents concurrent execution of those functions." See http://www.grails.org/version/Services/2 ("Services and scopes")