title: Why a pool of stateless EJB is needed
body: <p>I know that:</p>
  
  <blockquote>
    <p>For stateless session beans the server can maintain a variable amount
    of instances in a pool.
    Each time a client requests such a stateless bean (e.g. through a
    method) a random instance is chosen to serve that request.</p>
  </blockquote>
  
  <p>My question is: Why a pool is needed?
  Shouldn't one instance of a EJB stateless bean be enough to serve all requests ?</p>
  
  <p>Also if the server for a given stateless bean is using a pool of 10 instances,
  is 10 the maximum number of requests it can handle on such a bean ?</p>
  
  <p>Can you help me clear my doubt?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <blockquote>
    <p>section 4.3.14 of the ejb 3.1 spec gives the answer.</p>
    
    <p>4.3.14 Serializing Session Bean Methods The following requirements apply to Stateless and Stateful session beans. See Section 4.8.5 for
    Singleton session bean concurrency requirements.</p>
    
    <p>The container serializes calls to each stateful and stateless session
    bean instance. Most containers will support many instances of a
    session bean executing concurrently; however, each instance sees only
    a serialized sequence of method calls. Therefore, a stateful or
    stateless session bean does not have to be coded as reentrant.</p>
    
    <p>The container must serialize all the container-invoked callbacks (that
    is, the business method interceptor methods, lifecycle callback
    interceptor methods, timeout callback methods, beforeCompletion, and
    so on), and it must serialize these callbacks with the client-invoked
    business method calls.</p>
  </blockquote>
  
  <p>Searching a bit online, my quess is that a thread pool is necessary
  to the specification that imposes that EJB stateless methods
  are thread safe.
  So if we have,say 10 beans in the pool, only 10 requests can be served simultaneously, the other will be queued and assigned to the first free bean.
  Please correct me if I'm wrong.</p>