On 8/14/2019 6:07 PM, Jerry Malcolm wrote:

On 8/14/2019 5:39 PM, Mark Thomas wrote:
On 14/08/2019 23:35, Jerry Malcolm wrote:
On 8/14/2019 5:26 PM, Mark Thomas wrote:
On 14/08/2019 23:09, Jerry Malcolm wrote:
In my previous environment, I had a dedicated MySQL install where I
could set the max connections to pretty much anything I wanted. Now I'm moving to AWS where more connections mean a higher charge.  So it's time
to get real about how many connections I really need. BTW, TC 8.5.xx.

I 'thought' I understood defining a datasource.  I thought that if I set a maxTotal of 25 it sets a fixed ceiling and the datasource pool would never request more than 25 connections from the database. But with the
following datasource definition, mySQL shows 48 connections created.,
and JConsole shows 48 connections for this datasource.  In the same
MBean panel, it shows maxTotal=25 (??).  My app gets a bunch of "Server
says Too Many Connections" exceptions.

What am I missing?
What is the full path to:
- the file below
- CATALINA_BASE
- CATALINA_HOME
?

Mark
CATALINA_BASE:         /usr/share/tomcat8
CATALINA_HOME:         /usr/share/tomcat8

/etc/tomcat8/Catalina/<hostname>/context.xml.default
That is the default context.xml file that gets applied to every web
application. I'm guessing you have two web applications so a maximum of
2 * 25 connections - which is not what you want.

If the context path is "/abcd" then you should use:
/etc/tomcat8/Catalina/<hostname>/abcd.xml

(assuming /etc/tomcat8/ has been configured as the configBase).

For the ROOT web application (context path "") the file would be:
/etc/tomcat8/Catalina/<hostname>/ROOT.xml

Mark

Mark,

Hmm, right... I do have it wrong.   However, I don't think I want a different datasource for every web app.  Each webapp could need, say, 100 concurrent connections at any one instant.  But if there are 10 web apps, if I set all 10 to have a max of 100 in order to handle the worst case scenario, then I'll need to have at least 1000 connections available on the database.  Correct? But, in reality, I likely will never have more than 250 concurrent connections in use at any one time across all of the webapps.  So as long as all webapps are accessing the same database,  it seems it would make sense to have a single shared datasource with a max of 250 connections that are sharable by all of the webapps.  It would save me paying for 750 more connections on the database than I really need.

So, even though I agree I've got the config wrong currently, is there a way to set up a single datasource per hostname that can be shared by all webapps in that host with one global sharable maxTotal?  I don't want to use global resources, since the same "jdbc/xyz" datasource name points to a different database per virtual host.

Thanks for educating me.

Jerry

I was able to use a global resource and put a <ResourceLink> in the default context file for each host.  I changed my code to extract the host name from the request object and use that as the unique global dataSource name for that host. It looks like I possibly could have changed the name of the dataSource in the link, and used name="jdbc/xyz" global="jdbc/<hostname>" so the code could always reference "xyz" dataSource.  But I was already into changing the datasource names to the host names.  It works, which is good enough for now.

One last question...  is there a way to determine the high-water mark for the most active connections at any one instant?  And along with that, the max number of requests waiting at any one point if all connections are in use?  If I have way over-allocated maxTotal, I'd like to know that.   And likewise, if I've under-allocated maxTotal and often have a bunch of requests waiting, I'd like to know that as well.  Is there a way to track that?  I looked at the MBean data in JConsole, and nothing obvious jumped out at me.

Thanks.

Jerry




This is running on an AWS Linux EC2.

<Context reloadable="true" crossContext="true" >
     <Resource name="jdbc/------"
     auth="Container"
     type="javax.sql.DataSource"
     maxTotal="25"
     maxIdle="5"
     maxWaitMillis="10000"
     removeAbandonedOnBorrow="true"
     removeAbandonedTimeout="60"
     logAbandoned="true"
     username="----"
     password="----------"
     driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://---------------------.us-east-1.rds.amazonaws.com
/----------" />
</Context>




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to