Search code examples
javawebsphereconnection-poolingwebsphere-8spring-restcontroller

How websphere manages connection pool through datasource for multiple requests


I have a spring rest api which is hosted on websphere application server 8.5. which uses datasource to connect to the database and store the values The api handles around 10000 concurrent requests. What i really want to know if the maximum connections which are set to 10. How the connection pool works to connect to the database and how many sessions does it really create to achieve the load of upto 10000 concurrent requests.


Solution

  • Connections in the connection pool are shared by the WebContainer threads. The connection pool maximum size limits the number of connections that will be opened to the database. Normally connections are returned to the pool when the thread is complete. Faster return to the connection pool can be achieved if the connections are set to unshared in the application (however, there are some transactional reasons for not doing this so you will have to test the app with the setting both true and false see https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/cdat_conshrnon.html ).

    The number of concurrent requests the application server can handle is dependent on (a) size of the WebContainer thread pool and (b) the number of available connections in the connection pool and (c)the number of JVMs running the application and (d) how long the database takes to process the requests and (e) what else the application code does.

    There is no single number that works for every application but general rule of thumb is to have a larger WebContainer thread pool than the connection pool. If the requests process quickly then a larger number of concurrent requests can be processed. Likewise, if the requests are slow to process then the number of concurrent requests goes down. See https://publib.boulder.ibm.com/httpserv/cookbook/WebSphere_Application_Server-WAS_Traditional-Thread_Pools.html and https://publib.boulder.ibm.com/httpserv/cookbook/WebSphere_Application_Server-WAS_Traditional-Java_Database_Connectivity_JDBC.html

    You can monitor the JVM using techniques as outlined in https://www.ibm.com/developerworks/websphere/library/techarticles/0304_polozoff/polozoff.html and here https://www-01.ibm.com/software/webservers/appserv/was/performance.html

    What I like to do is to size a single JVM for best performance (i.e. you'll have bottlenecks in any application that will restrict how many concurrent requests can be processed by a single JVM) and then scale out horizontally (for failover) and then vertically for scale until I hit the Service Level Agreement (SLA) for the number of concurrent requests. You'll probably also need to look at Non Functional Requirements (NFRs) in the application to address any performance aspects.

    Let me know if you have any followup questions.