Re: tomcat jdbc pool, creating a pool of pools, single connection memory footprint

2014-08-20 Thread S Ahmed
2 years later ...

OK this sounds like the best approach as it lets you scale things out as
you grow and actually need more servers (then you just have to manage which
database to switch too).

The cons of this approach is that most ORM's don't support this.


On Fri, Jun 1, 2012 at 2:37 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Ahmed,
>
> On 5/31/12 9:33 AM, S Ahmed wrote:
> >> It would be easier if all databases were hosted by a single
> >> instance of MySQL -- then you could use Tomcat-pool's feature of
> >> being able to provide credentials when obtaining connections from
> >> the pool -- and get the right database. That way, a much smaller
> >> number of connections could be maintained with roughly the same
> >> semantics.
> >
> > Can you expand on how I could do this?
>
> Well, first you have to accept that the same MySQL instance (with
> perhaps different databases) will be hosting all your data. If that's
> not okay with you, then you can forget this suggestion (or, maybe it
> just changes the suggestion slightly because you could always have N
> databases and maybe 4 MySQL instances when them split across the 4...
> but then you'd have to figure out which connection pool to grab before
> getting a connection or you'd never get connected).
>
> Next, you'd have to switch to tomcat-pool because commons-dbcp (the
> default CP in Tomcat) does not support obtaining pooled connections
> with credentials.
>
> Next, you remove the database name from the JDBC URL (or maybe change
> it to something everyone can access, like the 'test' database or
> 'information_schema' depending on your version of MySQL).
>
> Then, you have your code call
> DataSource.getConnection(username,password) instead of calling
> DataSource.getConnection(). This gets you the right credentials for
> your target database.
>
> Finally, make sure you issue a query to set the database for the
> connection:
>
> 'USE databasename;'
>
> Then, you set your connection pool to have however many connections
> you want (100?) and every client (thread) shares those connections
> with every client database that runs in a particular MySQL instance.
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk/JC8wACgkQ9CaO5/Lv0PBEpgCghI3t8gpE+SBSNV/pYjyLqqwq
> 2hwAoIY8mYqGGG+owxzsFPQ+CFa2cVeL
> =Fh/Y
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


understanding jdbc pool

2014-03-05 Thread S Ahmed
Hi,

With jdbc pool, is each socket connection in the pool handled by a separate
thread?

Say you have 20 connections set to be open at minimum, does that mean there
will be 20 threads?  If not, then there is a degree of serialization then
right?


Re: jdbc connection debugging, tips?

2012-11-13 Thread S Ahmed
Ok it turns out it was bound to an private ip address on ec2, thanks Dan!


On Tue, Nov 13, 2012 at 10:52 PM, S Ahmed  wrote:

> ubuntu:~$ mysql -u root -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 58
> Server version: 5.1.63-0ubuntu0.11.04.1-log (Ubuntu)
>
> Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights
> reserved.
>
> Oracle is a registered trademark of Oracle Corporation and/or its
> affiliates. Other names may be trademarks of their respective
> owners.
>
> Type 'help;' or '\h' for help. Type '\c' to clear the current input
> statement.
>
> mysql> exit
> Bye
> ubuntu:~$ telnet localhost 3306
> Trying 127.0.0.1...
> telnet: Unable to connect to remote host: Connection refused
> ubuntu:~$ telnet 127.0.0.1 3306
> Trying 127.0.0.1...
> telnet: Unable to connect to remote host: Connection refused
> ubuntu:~$ cat /etc/hosts
> 127.0.0.1 localhost
>
> # The following lines are desirable for IPv6 capable hosts
> ::1 ip6-localhost ip6-loopback
> fe00::0 ip6-localnet
> ff00::0 ip6-mcastprefix
> ff02::1 ip6-allnodes
> ff02::2 ip6-allrouters
> ff02::3 ip6-allhosts
> ubuntu:~$
>
> ubuntu:~$ cat /etc/issue
> Ubuntu 11.04 \n \l
>
>
>
>
>
> On Tue, Nov 13, 2012 at 11:16 AM, S Ahmed  wrote:
>
>> I'll report back tonight, thanks again!
>>
>>
>> On Tue, Nov 13, 2012 at 11:08 AM, Daniel Mikusa wrote:
>>
>>> On Nov 13, 2012, at 9:55 AM, S Ahmed wrote:
>>>
>>> > Dan,
>>> >
>>> > Thanks for your help.
>>> >
>>> > From the terminal I was very explicit, I did this:
>>> >
>>> >> mysql --host localhost --port 3306 --user myuser --password
>>> >> password: 123
>>> >
>>> > And it worked fine.  In my log4net, I believe I set jdbc logs to be
>>> ALL or
>>> > DEBUG (i'll check when I get home), but it didn't output the host and
>>> > password (just in case it is reading from the wrong file somehow??).
>>>
>>> It's not an issue of a wrong user / pass, the exception is saying that
>>> it literally cannot connect to the host that you've specified.
>>>
>>> >>> Caused by: java.net.ConnectException: Connection refused
>>>
>>> Can you include the output from the following commands?
>>>
>>> telnet localhost 3306
>>> telnet 127.0.0.1 3306
>>> cat /etc/hosts
>>>
>>> You might also want to enable wireshark and see what is happening when
>>> your application starts.
>>>
>>> Dan
>>>
>>>
>>>
>>> >
>>> >
>>> >
>>> > On Tue, Nov 13, 2012 at 8:18 AM, Daniel Mikusa 
>>> wrote:
>>> >
>>> >> On Nov 12, 2012, at 10:55 PM, S Ahmed wrote:
>>> >>
>>> >>> I can't seem to connect to my mysql database from my java code, but
>>> I can
>>> >>> do it via terminal using the user and password that is in my spring
>>> >> context
>>> >>> file.
>>> >>>
>>> >>> I also tried modifying it to localhost:3306 but that didn't change
>>> >> anything
>>> >>> (it defaults to 3306).
>>> >>
>>> >> Have you tried using 127.0.0.1 or the IP address of the machine?
>>>  Perhaps
>>> >> something is not right in your /etc/hosts file and it is unable to
>>> lookup
>>> >> localhost.
>>> >>
>>> >>>
>>> >>> Both the application and mysql are on the same server (ec2).
>>> >>>
>>> >>> What can I do to figure out the issue?  I'm lost!
>>> >>>
>>> >>> my xml file has:
>>> >>>
>>> >>>   >> class="org.apache.tomcat.jdbc.pool.DataSource"
>>> >>> destroy-method="close">
>>> >>>   >> value="com.mysql.jdbc.Driver"/>
>>> >>>   
>>> >>>   
>>> >>>   
>>> >>>
>>> >>>   
>>> >>>   
>>> >>>   
>>> >>>   
>>> >>>   
>>> >>>   
>>> >>>
>>> >>>   
>>> >>>   
>>> >>>
>>> >

Re: jdbc connection debugging, tips?

2012-11-13 Thread S Ahmed
ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 58
Server version: 5.1.63-0ubuntu0.11.04.1-log (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

mysql> exit
Bye
ubuntu:~$ telnet localhost 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
ubuntu:~$ telnet 127.0.0.1 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
ubuntu:~$ cat /etc/hosts
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
ubuntu:~$

ubuntu:~$ cat /etc/issue
Ubuntu 11.04 \n \l





On Tue, Nov 13, 2012 at 11:16 AM, S Ahmed  wrote:

> I'll report back tonight, thanks again!
>
>
> On Tue, Nov 13, 2012 at 11:08 AM, Daniel Mikusa wrote:
>
>> On Nov 13, 2012, at 9:55 AM, S Ahmed wrote:
>>
>> > Dan,
>> >
>> > Thanks for your help.
>> >
>> > From the terminal I was very explicit, I did this:
>> >
>> >> mysql --host localhost --port 3306 --user myuser --password
>> >> password: 123
>> >
>> > And it worked fine.  In my log4net, I believe I set jdbc logs to be ALL
>> or
>> > DEBUG (i'll check when I get home), but it didn't output the host and
>> > password (just in case it is reading from the wrong file somehow??).
>>
>> It's not an issue of a wrong user / pass, the exception is saying that it
>> literally cannot connect to the host that you've specified.
>>
>> >>> Caused by: java.net.ConnectException: Connection refused
>>
>> Can you include the output from the following commands?
>>
>> telnet localhost 3306
>> telnet 127.0.0.1 3306
>> cat /etc/hosts
>>
>> You might also want to enable wireshark and see what is happening when
>> your application starts.
>>
>> Dan
>>
>>
>>
>> >
>> >
>> >
>> > On Tue, Nov 13, 2012 at 8:18 AM, Daniel Mikusa 
>> wrote:
>> >
>> >> On Nov 12, 2012, at 10:55 PM, S Ahmed wrote:
>> >>
>> >>> I can't seem to connect to my mysql database from my java code, but I
>> can
>> >>> do it via terminal using the user and password that is in my spring
>> >> context
>> >>> file.
>> >>>
>> >>> I also tried modifying it to localhost:3306 but that didn't change
>> >> anything
>> >>> (it defaults to 3306).
>> >>
>> >> Have you tried using 127.0.0.1 or the IP address of the machine?
>>  Perhaps
>> >> something is not right in your /etc/hosts file and it is unable to
>> lookup
>> >> localhost.
>> >>
>> >>>
>> >>> Both the application and mysql are on the same server (ec2).
>> >>>
>> >>> What can I do to figure out the issue?  I'm lost!
>> >>>
>> >>> my xml file has:
>> >>>
>> >>>   > >>> destroy-method="close">
>> >>>   
>> >>>   
>> >>>   
>> >>>   
>> >>>
>> >>>   
>> >>>   
>> >>>   
>> >>>   
>> >>>   
>> >>>   
>> >>>
>> >>>   
>> >>>   
>> >>>
>> >>>   
>> >>>
>> >>> This is the error I am getting:
>> >>>
>> >>> Exception in thread "main"
>> >>> org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
>> get
>> >>> JDBC Connection; nested exception is
>> >>> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
>> Communications
>> >>> link failure
>> >>>
>> >> 
>> >>>
>> >>> Caused by: java.net.ConnectException: Connection refused
>> >>> at java.net.PlainSocketImpl.socketConnect(Native Method)
>> >>> at
>> >>>
>> >>
>> java.net.AbstractPlainSocketImpl.doConnect(Abstract

Re: jdbc connection debugging, tips?

2012-11-13 Thread S Ahmed
I'll report back tonight, thanks again!


On Tue, Nov 13, 2012 at 11:08 AM, Daniel Mikusa  wrote:

> On Nov 13, 2012, at 9:55 AM, S Ahmed wrote:
>
> > Dan,
> >
> > Thanks for your help.
> >
> > From the terminal I was very explicit, I did this:
> >
> >> mysql --host localhost --port 3306 --user myuser --password
> >> password: 123
> >
> > And it worked fine.  In my log4net, I believe I set jdbc logs to be ALL
> or
> > DEBUG (i'll check when I get home), but it didn't output the host and
> > password (just in case it is reading from the wrong file somehow??).
>
> It's not an issue of a wrong user / pass, the exception is saying that it
> literally cannot connect to the host that you've specified.
>
> >>> Caused by: java.net.ConnectException: Connection refused
>
> Can you include the output from the following commands?
>
> telnet localhost 3306
> telnet 127.0.0.1 3306
> cat /etc/hosts
>
> You might also want to enable wireshark and see what is happening when
> your application starts.
>
> Dan
>
>
>
> >
> >
> >
> > On Tue, Nov 13, 2012 at 8:18 AM, Daniel Mikusa 
> wrote:
> >
> >> On Nov 12, 2012, at 10:55 PM, S Ahmed wrote:
> >>
> >>> I can't seem to connect to my mysql database from my java code, but I
> can
> >>> do it via terminal using the user and password that is in my spring
> >> context
> >>> file.
> >>>
> >>> I also tried modifying it to localhost:3306 but that didn't change
> >> anything
> >>> (it defaults to 3306).
> >>
> >> Have you tried using 127.0.0.1 or the IP address of the machine?
>  Perhaps
> >> something is not right in your /etc/hosts file and it is unable to
> lookup
> >> localhost.
> >>
> >>>
> >>> Both the application and mysql are on the same server (ec2).
> >>>
> >>> What can I do to figure out the issue?  I'm lost!
> >>>
> >>> my xml file has:
> >>>
> >>>>>> destroy-method="close">
> >>>   
> >>>   
> >>>   
> >>>   
> >>>
> >>>   
> >>>   
> >>>   
> >>>   
> >>>   
> >>>   
> >>>
> >>>   
> >>>   
> >>>
> >>>   
> >>>
> >>> This is the error I am getting:
> >>>
> >>> Exception in thread "main"
> >>> org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
> get
> >>> JDBC Connection; nested exception is
> >>> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
> >>> link failure
> >>>
> >> 
> >>>
> >>> Caused by: java.net.ConnectException: Connection refused
> >>> at java.net.PlainSocketImpl.socketConnect(Native Method)
> >>> at
> >>>
> >>
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
> >>> at
> >>>
> >>
> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
> >>> at
> >>>
> >>
> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
> >>> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
> >>> at java.net.Socket.connect(Socket.java:546)
> >>> at java.net.Socket.connect(Socket.java:495)
> >>> at java.net.Socket.(Socket.java:392)
> >>> at java.net.Socket.(Socket.java:235)
> >>> at
> >>>
> >>
> com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
> >>> at com.mysql.jdbc.MysqlIO.(MysqlIO.java:300)
> >>> ... 29 more
> >>
> >> Seems like the root cause is that a connection cannot be made to the
> >> server.  Double check your credentials.  Also, how are you testing from
> the
> >> terminal?  Can you run "telnet localhost 3306"?
> >>
> >> Dan
> >>
> >>
> >>
> >> -
> >> 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
>
>


Re: jdbc connection debugging, tips?

2012-11-13 Thread S Ahmed
Dan,

Thanks for your help.

>From the terminal I was very explicit, I did this:

>mysql --host localhost --port 3306 --user myuser --password
>password: 123

And it worked fine.  In my log4net, I believe I set jdbc logs to be ALL or
DEBUG (i'll check when I get home), but it didn't output the host and
password (just in case it is reading from the wrong file somehow??).




On Tue, Nov 13, 2012 at 8:18 AM, Daniel Mikusa  wrote:

> On Nov 12, 2012, at 10:55 PM, S Ahmed wrote:
>
> > I can't seem to connect to my mysql database from my java code, but I can
> > do it via terminal using the user and password that is in my spring
> context
> > file.
> >
> > I also tried modifying it to localhost:3306 but that didn't change
> anything
> > (it defaults to 3306).
>
> Have you tried using 127.0.0.1 or the IP address of the machine?  Perhaps
> something is not right in your /etc/hosts file and it is unable to lookup
> localhost.
>
> >
> > Both the application and mysql are on the same server (ec2).
> >
> > What can I do to figure out the issue?  I'm lost!
> >
> > my xml file has:
> >
> > > destroy-method="close">
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > This is the error I am getting:
> >
> > Exception in thread "main"
> > org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get
> > JDBC Connection; nested exception is
> > com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
> > link failure
> >
> 
> >
> > Caused by: java.net.ConnectException: Connection refused
> > at java.net.PlainSocketImpl.socketConnect(Native Method)
> > at
> >
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
> > at
> >
> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
> > at
> >
> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
> > at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
> > at java.net.Socket.connect(Socket.java:546)
> > at java.net.Socket.connect(Socket.java:495)
> > at java.net.Socket.(Socket.java:392)
> > at java.net.Socket.(Socket.java:235)
> > at
> >
> com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
> > at com.mysql.jdbc.MysqlIO.(MysqlIO.java:300)
> > ... 29 more
>
> Seems like the root cause is that a connection cannot be made to the
> server.  Double check your credentials.  Also, how are you testing from the
> terminal?  Can you run "telnet localhost 3306"?
>
> Dan
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: jdbc connection debugging, tips?

2012-11-12 Thread S Ahmed
This same setup works fine locally on my laptop..so it does work :)


On Mon, Nov 12, 2012 at 10:55 PM, S Ahmed  wrote:

> I can't seem to connect to my mysql database from my java code, but I can
> do it via terminal using the user and password that is in my spring context
> file.
>
> I also tried modifying it to localhost:3306 but that didn't change
> anything (it defaults to 3306).
>
> Both the application and mysql are on the same server (ec2).
>
> What can I do to figure out the issue?  I'm lost!
>
> my xml file has:
>
>  destroy-method="close">
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
>
> 
> 
>
> 
>
> This is the error I am getting:
>
> Exception in thread "main"
> org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get
> JDBC Connection; nested exception is
> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
> link failure
>
> The last packet sent successfully to the server was 0 milliseconds ago.
> The driver has not received any packets from the server.
> at
> org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
>  at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
> at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
>  at
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:464)
> at A.data.jdbc.PlanTypeDaoImpl.findAllActive(PlanTypeDaoImpl.java:23)
>  at
> com.just.testing.services.PlanTypeServiceImpl.getPlanTypesMap(PlanTypeServiceImpl.java:33)
> at com.just.testing.http.HttpErrorServer.main(HttpErrorServer.java:36)
> Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
> Communications link failure
>
> The last packet sent successfully to the server was 0 milliseconds ago.
> The driver has not received any packets from the server.
>  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>  at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
>  at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
> at
> com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
>  at com.mysql.jdbc.MysqlIO.(MysqlIO.java:350)
> at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2393)
>  at
> com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)
> at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)
>  at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:813)
> at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
>  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>  at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
>  at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
> at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
>  at
> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
> at
> org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:277)
>  at
> org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
> at
> org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
>  at
> org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:631)
> at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:485)
>  at
> org.apache.tomcat.jdbc.pool.ConnectionPool.(ConnectionPool.java:143)
> at
> org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
>  at
> org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
> at
> org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
>  at
> org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
> at
> org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
>  ... 6 more
> Caused by: java.net.ConnectException: Connection refused
> at java.net.PlainSocketImpl.socketConnect(Native Method)
>  at
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
> at
> java.net.Abst

Re: tomcat jdbc

2012-10-23 Thread S Ahmed
Ok from what I understood, if you want to capture statistics or look into
jmx related metrics, you have to manually fireup visualvm/jconsole i.e. be
on your computer, and monitor it as oppose to somethign that runs 24/7

On Mon, Oct 22, 2012 at 1:58 PM, Pid  wrote:

> On 22/10/2012 15:37, S Ahmed wrote:
> > I was thinking of using this: https://github.com/codahale/metrics
> >
> > Much easier to have this keep track of stats, and not having to rely on
> > jconsole just to get in insight.
>
> Why is it easier to instrument Tomcat's code than to just use the JMX
> info that's already exposed?
>
> VisualVM & JConsole are not monitoring tools, they just display the info
> that's already exposed.  Strongly recommend you at least familiarise
> yourself with what's in the Tomcat MBeans before you proceed.
>
>
> p
>
> > On Fri, Oct 19, 2012 at 5:37 PM, Pid  wrote:
> >
> >> On 19/10/2012 16:18, Daniel Mikusa wrote:
> >>> On Oct 18, 2012, at 2:51 PM, S Ahmed wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> When using the jdbc connection pool library, would it be possible to
> >>>> somehow record the # of connections that are being used,
> >>>> when the # of connections in the pool are being saturated etc., or is
> >> that something that
> >>>> would have to be modified in the library itself?
> >>>
> >>> The connection pool publishes some statistics to JMX.  An easy way to
> >> see them is connect with jconsole.  If you need more advanced
> statistics,
> >> you could check / monitor them programmatically or use an existing
> >> monitoring tool.
> >>
> >> +1  Use VisualVM with the MBeans plugin or JConsole.
> >>
> >>
> >> p
> >>
> >>> Dan
> >>>
> >>>
> >>>>
> >>>> i.e. assuming I have can keep track of these counters, is there a way
> to
> >>>> monitor these events in the library or would the jdbc library itself
> >> need
> >>>> to be modified to expose these events?
> >>>
> >>>
> >>>
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> >>> For additional commands, e-mail: users-h...@tomcat.apache.org
> >>>
> >>
> >>
> >> --
> >>
> >> [key:62590808]
> >>
> >>
> >
>
>
> --
>
> [key:62590808]
>
>


Re: tomcat jdbc

2012-10-22 Thread S Ahmed
I was thinking of using this: https://github.com/codahale/metrics

Much easier to have this keep track of stats, and not having to rely on
jconsole just to get in insight.

On Fri, Oct 19, 2012 at 5:37 PM, Pid  wrote:

> On 19/10/2012 16:18, Daniel Mikusa wrote:
> > On Oct 18, 2012, at 2:51 PM, S Ahmed wrote:
> >
> >> Hi,
> >>
> >> When using the jdbc connection pool library, would it be possible to
> >> somehow record the # of connections that are being used,
> >> when the # of connections in the pool are being saturated etc., or is
> that something that
> >> would have to be modified in the library itself?
> >
> > The connection pool publishes some statistics to JMX.  An easy way to
> see them is connect with jconsole.  If you need more advanced statistics,
> you could check / monitor them programmatically or use an existing
> monitoring tool.
>
> +1  Use VisualVM with the MBeans plugin or JConsole.
>
>
> p
>
> > Dan
> >
> >
> >>
> >> i.e. assuming I have can keep track of these counters, is there a way to
> >> monitor these events in the library or would the jdbc library itself
> need
> >> to be modified to expose these events?
> >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
>
>
> --
>
> [key:62590808]
>
>


Re: tomcat jdbc

2012-10-19 Thread S Ahmed
Thanks.

But this doesn't give me information like, say my pool is 10 connections,
and my application is getting more traffic and those connections are all
used up and there are 5 other callers waiting for a free connection, that
informaiton isn't exposed and I want to create counters somehow to monitor
this.

On Fri, Oct 19, 2012 at 8:53 AM, Mark Shifman  wrote:

> On 10/18/2012 02:51 PM, S Ahmed wrote:
>
>> Hi,
>>
>> When using the jdbc connection pool library, would it be possible to
>> somehow record the # of connections that are being used, when the # of
>> connections in the pool are being saturated etc., or is that something
>> that
>> would have to be modified in the library itself?
>>
> You can see the connections by doing an appropriate select on your
> database.  For oracle select v$session like
>
> select username, program, machine, client_identifier, osuser,logon_time,
>  sid, serial#
> from v$session where osuser != 'oracle' order by program, machine,
> client_identifier, logon_time
>
> There is also a simple way to see the connections in mysql but I can't
> remember it
>
>
>> i.e. assuming I have can keep track of these counters, is there a way to
>> monitor these events in the library or would the jdbc library itself need
>> to be modified to expose these events?
>>
>>
> --
>  Mark Shifman MD. Ph.D.
>  Yale Center for Medical Informatics
>  Phone (203)737-5219
>  mark.shif...@yale.edu
>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@tomcat.**apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: pushing updates to a running tomcat instance

2012-10-15 Thread S Ahmed
so when you don't have reloads enabled, any updates (copying a new version
of a .jar) to a folder will not do anything?

This is a spring mvc application, and I'm scared of leaks via logging etc.,
I'll take the safe route and just recycle or whatever I have to do.

I have to explicitly start/stop the service if am doing this via the
command line?

On Mon, Oct 15, 2012 at 12:45 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> S Ahmed,
>
> On 10/15/12 11:39 AM, S Ahmed wrote:
> > So when I have my server setup with tomcat, I normally do this
> > first:
> >
> > sudo mv /var/lib/tomcat6/webapps/ROOT/
> > /var/lib/tomcat6/webapps/old_ROOT
> >
> > I then move my .war file:
> >
> > sudo cp hello_world_war.war
> > /var/lib/tomcat6/webapps/hello_world_war.war
>
> If you have a large WAR file, you might want to copy it somewhere else
> first, then 'mv' it. Otherwise, Tomcat might attempt to re-deploy the
> WAR file before the copy is complete. Maybe:
>
> sudo cp hello_world_war.war /var/lib/tomcat6/staging/hello_world_war.war
> sudo mv /var/lib/tomcat6/webapps/hello_world_war.war \
> /var/lib/tomcat6/webapps/hello_world_war.war
> sudo mv /var/lib/tomcat6/staging/hello_world_war.war \
> /var/lib/tomcat6/webapps/hello_world_war.war
>
> > And everything works as expected for me.
> >
> > Now say locally in development I update a .jar file, and I want to
> > push a hotfix to my server.
> >
> > What is the best way to do this? If I simply ftp the file and copy
> > it to the correct folder in my expanded war, will that suffice w/o
> > downtime?
>
> There is always some measurable "downtime" here, even if it is just
> that requests are queued while the webapp reloads.
>
> I usually don't run in production with 'reloadable' enabled because a)
> I don't want any surprise reloads and b) I don't want to waste any
> resources checking for file updates.
>
> If you are not enabling 'reloadable' and want to reload the context,
> consider using the manager webapp to explicitly reload the context.
> During the reload, Tomcat should queue all requests to the reloading
> webapp and allow them to continue once the webapp has relaoded.
>
> Just make sure that the webapp a) doesn't leak any resources when it
> reloads and b) doesn't take forever to reload.
>
> Hope that helps,
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlB8PakACgkQ9CaO5/Lv0PAtsQCeKRhKXcTtJkCd1JQ5AsIP6uzY
> 7l0An14ZjVnzD4OsVxIhB30LT7l3Pzze
> =1aiJ
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: tomcat jdbc pool, creating a pool of pools, single connection memory footprint

2012-05-31 Thread S Ahmed
>It would be easier if all databases were hosted by a single instance
>of MySQL -- then you could use Tomcat-pool's feature of being able to
>provide credentials when obtaining connections from the pool -- and
>get the right database. That way, a much smaller number of connections
>could be maintained with roughly the same semantics.
Can you expand on how I could do this?

Thanks for the insights.  I think in reality there would be multiple
databases per server.  For example, when I purchase shared hosting, you can
query for all the databases and you can see there are hundreds of db's for
each customer.  If a customer's traffic is high enough, I could move them
to another server.

Also, seeing as 2GB would be required, and the file handler issue, I was
thinking one could segment sites into clusters, so each cluster would be
responsible for n number of websites (thus reducing the # of pools required
per application server).

On Thu, May 31, 2012 at 2:56 AM, Pid *  wrote:

> On 31 May 2012, at 00:49, Christopher Schultz
>  wrote:
>
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA1
> >
> > André,
> >
> > On 5/30/12 6:18 PM, André Warnier wrote:
> >> Taking the same hypothetical case and figures :
> >>
> >> Assuming that you need a total of (1 * 4 connections) = 4
> >> connections. Assuming that it takes 10ms to set up one such
> >> connection, and that once it is there, you don't do anything with
> >> it and just let it be for now. Assuming we ignore such things like
> >> bandwidth, other things happening on that host etc.. It then takes
> >> a total of (10 ms * 4) = 40 ms = 400s = ~ 6.5 minutes just
> >> to set up these connections.
> >>
> >> Is that acceptable ?
> >>
> >> What I mean is that once you start playing with such numbers, you
> >> may want to look at other aspects than just required memory..
> >
> > There's also the issue of open filehandles, etc. My development
> > environment is limited to 10240 filehandles per process (though of
> > course that can be changed). Opening 10,000 connections would use most
> > of those, leaving very few left to accept incoming requests from
> > clients, etc.
>
> Ah, beat me to it.
>
>
> p
>
> > It would be easier if all databases were hosted by a single instance
> > of MySQL -- then you could use Tomcat-pool's feature of being able to
> > provide credentials when obtaining connections from the pool -- and
> > get the right database. That way, a much smaller number of connections
> > could be maintained with roughly the same semantics.
> >
> > - -chris
> > -BEGIN PGP SIGNATURE-
> > Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> > Comment: GPGTools - http://gpgtools.org
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> >
> > iEYEARECAAYFAk/GsecACgkQ9CaO5/Lv0PC7HACeNXMp5KZpAHGfhK73/MPFcGOn
> > eIwAoJ7g4P/Nz2DBgNHBhwkq0jO3HMCu
> > �CE
> > -END PGP SIGNATURE-
> >
> > -
> > 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
>
>


Re: tomcat jdbc pool, creating a pool of pools, single connection memory footprint

2012-05-30 Thread S Ahmed
Chris,

Great thanks that is exactly what I was looking for, just to get an idea at
this point.

And yes it was for mysql.

I was thinking one could create a smarter pool, one that created more
connections for sites used more often, and less for others.

Much appreciated.

On Wed, May 30, 2012 at 10:07 AM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Ahmed,
>
> On 5/29/12 9:29 AM, S Ahmed wrote:
> > If my requirement for a hosted application is to give each
> > customer a separate instance of mysql, I am curious how feasible
> > that would be.
>
> You can certainly do this.
>
> > What is the memory footprint for a single connection to a
> > database?
>
> That depends a lot of which database you are using (MySQL connections
> are fairly modest: the "retained size" of one of my MySQL
> JDBC4Connection objects is 66k in an x86-64 environment with a 64-bit
> Sun/Oracle JVM), what things you are having cached/pooled on the
> client side, etc. You'd have to give us a lot more information about
> your environment. Better yet, configure it the way you want it and use
> a profiler to see how "big" the connections become.
>
> > If I had 10K separate mysql instances, would it be feasible to
> > create a pool of pools? i.e. a hashmap of connection pools?
>
> That sounds like a lot of MySQL instances to be contacted by a single
> application server. Do you need 10k separate customers all running in
> the same webapp?
>
> If my environment and requirements match yours, you'd need 1 *
> max_pool_size * 66KiB at peak usage. That's about 640MiB for each
> connection you want in 10k pools. For a (uniform) max pool size of 4,
> you'll need more than 2GiB of heap space just for connection pools.
>
> Is that acceptable?
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk/GKb8ACgkQ9CaO5/Lv0PBmCACghH4L1ycmK1UwHHPq1aVu0Sxn
> X2IAnjePQzdy5iMAL5pEIe0KgxRY1q8V
> =Uieg
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: jdbc pool properties

2012-04-06 Thread S Ahmed
I'm using tomcat 7, in a spring mvc application.  The properties is in my
spring-context.xml file.

 

















On Fri, Apr 6, 2012 at 2:09 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Daniel,
>
> On 4/4/12 8:46 AM, Daniel Mikusa wrote:
> > - Original Message -
> >> My db connections seem to be lost after an extended period of
> >> inactivity (for a web application). And the only way to get the
> >> connections to work again is to restart tomcat.
> >>
> >> My tomcat.jdbc.pool.Datasource settings have:
> >>
> >>   >> value="30"/>   >> name="defaultAutoCommit" value="true"/>  >> name="removeAbandoned" value="true"/>  >> name="removeAbandonedTimeout" value="60"/>
> >
> > You probably want to add testOnBorrow="true" and
> > "validationQuery=SELECT 1"  (or some other valid query for your
> > DB).
>
> +1
>
> > See the following link for an explanation of those properties.
> >
> > https://commons.apache.org/dbcp/configuration.html
>
> - -1
>
> This is the wrong documentation for tomcat-pool. You're looking for
> http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
>
> On the other hand, there was no mention of a Tomcat version, what type
> of pool is actually being used (I inferred tomcat-pool from the
> subject line as well as the use of "tomcat.jdbc.pool.DataSource") and
> the use of  elements seems antiquated, so I must admit I'm a
> little confused.
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk9/MWAACgkQ9CaO5/Lv0PCcOgCeJcRA6Oq2KcVSDE6vIAmQ+5Ji
> lJUAoL4QiLp1oZSBVkiaFYTrJTlK6Gkv
> =wFzD
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: jdbc pool properties

2012-04-05 Thread S Ahmed
Daniel,

Your suggestion seems to have worked so far, thanks!

testOnBorrow="true" and "validationQuery=SELECT 1"

On Wed, Apr 4, 2012 at 8:46 AM, Daniel Mikusa  wrote:

>
>
> - Original Message -
> > My db connections seem to be lost after an extended period of
> > inactivity
>
> There could be a number of reasons that this occurs.  Perhaps a network
> issue is causing them to be disconnected or the database may be timing them
> out.  At any rate, it's not likely that the problem would be caused by the
> "removeAbandoned" / "abandonedTimeout" settings, unless you application is
> not properly returning connections to the connection pool.
>
>
> https://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Preventing_database_connection_pool_leaks
>
>
> > (for a web application).  And the only way to get the connections to
> > work
> > again is to restart tomcat.
> >
> > My tomcat.jdbc.pool.Datasource settings have:
> >
> >  
> > 
> > 
> > 
> > 
> > 
> >
>
> You probably want to add testOnBorrow="true" and "validationQuery=SELECT
> 1"  (or some other valid query for your DB).  See the following link for an
> explanation of those properties.
>
>  https://commons.apache.org/dbcp/configuration.html
>
> This will cause your connections to be validated prior to their use by
> your application.  Stale connections will be removed and replaced with new,
> working connections.
>
> >
> > Is it the removedAbonded and abandonedTimeout?  Does it mean "after
> > 60
> > seconds, remove the connection from the pool?
>
> No.  See either of the links I've referenced above for an explanation of
> these settings.
>
> >
> > I guess what I need is a minActive setting then?
> >
>
> There's no "minActive" setting.  You have "minIdle", but I don't think
> that would help here.
>
> Dan
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: tomcat jdbc pool

2012-03-25 Thread S Ahmed
Why would you want to use a future?

Say in a web application, I can't really think of a reason why I would use
the future (asych) connection retrieval pattern.   The # of connections is
always fixed, I guess in a very high traffic environment where the # of
connections is the pool are used up, calling via a future will block he
request until a connection frees up right?

Could you also do this:  Send a sql query to the pool that you want to
execute in the beginning of the page, but you don't really care about the
return value until the end so you can let it go and then at the bottom you
call .get(), is that possible?

On Sun, Mar 25, 2012 at 6:41 PM, Konstantin Kolinko
wrote:

> 2012/3/26 S Ahmed :
> > Is the jdbc pool somehow married to tomcat or can I use it with other
> > containers potentially? (
>
> 1. You certainly can use it with other containers.
> But it depends on Tomcat version of logging library (That is
> tomcat-juli.jar). You have  to copy that jar as well.
>
>
> >> http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html)
>
> 2. The above link is obsolete.
>
> The current version of this pool implementation comes bundled with
> Tomcat 7.0 releases. The correct documentation is here:
>
> http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
>
> Best regards,
> Konstantin Kolinko
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: upgrading tomcat when installed via apt-get

2012-01-27 Thread S Ahmed
But before do that, you would have to know if the tomcat config file has
changed format wise correct?

e.g. if the server.xml file was updated  (I'm sure it is rare but still)

Can you please outline exactly what you do to upgrade tomcat?

thanks much appreciated!

On Fri, Jan 27, 2012 at 4:55 PM, Mark Thomas  wrote:

> On 27/01/2012 21:41, S Ahmed wrote:
> > If I need to upgrade an existing live application that is running off a
> > tomcat install that was installed via apt-get (ubuntu), how would I go
> > about updating tomcat?
>
> Don't know. That would be a question for an Ubuntu support forum.
>
> > I would have to understand exactly how tomcat is installed correct?  i.e.
> > things like xml conf files, symbolic links to paths that may have been
> > created, startup/stop scripts that might need to point somewhere else
> etc.
> >
> > Am I making this too complicated or is this how others update to a newer
> > version of tomcat?
>
> It depends. It isn't how I do it. I use separate CATALINA_HOME and
> CATALINA_BASE. Upgrades and downgrades are then trivial. For example,
> upgrading the ASF's Jira instances takes less than 2 minutes and most of
> that time is waiting for Jira to shutdown and startup.
>
> Mark
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: running separate isolated jvm's for each web app

2012-01-16 Thread S Ahmed
Meaning I have to run tomcat 2 times?

I thought it would be possible to have a single instace of tomcat running,
and 2 different applications running on seperate jvms.

Thanks for clarifying.

So there memory cost is even higher since you need 2 tomcats running.

On Mon, Jan 16, 2012 at 11:17 AM, Ilya Kazakevich <
ilya.kazakev...@jetbrains.com> wrote:

> Tomcat itself runs inside JVM, so you need 2 JVMs each with tomcat and your
> app.
> Separating apps is a good practice because of classpath issues
>
> Ilya Kazakevich,
> Developer
> JetBrains Inc
> http://www.jetbrains.com
> "Develop with pleasure!"
>
>
> >-Original Message-
> >From: S Ahmed [mailto:sahmed1...@gmail.com]
> >Sent: Monday, January 16, 2012 8:14 PM
> >To: Tomcat Users List
> >Subject: running separate isolated jvm's for each web app
> >
> >If my tomcat has 2 web applications running on it, how do I
> >create different jvm pools to keep the apps isolated?
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


running separate isolated jvm's for each web app

2012-01-16 Thread S Ahmed
If my tomcat has 2 web applications running on it, how do I create
different jvm pools to keep the apps isolated?


Re: clarification on how data is streamed and handled by tomcat

2012-01-04 Thread S Ahmed
" But if you call certain APIs (e.g. getParameter()) the call will hang
until entire POST request body is received from the client and
processed. "

So this means if you don't reference request.getParameter then it won't be
streamed from the client?

The reason I am asking is I will perform api usage limites, and it would be
great if I don't have to bring in the entire request header + body if I can
get away with it.

On Wed, Jan 4, 2012 at 1:58 PM, André Warnier  wrote:

> S Ahmed wrote:
>
>> Tomcat 6
>> Spring MVC, where my controllers method has both httpservletrequest and
>> httpservletresponse as parameters.
>>
>> The point is that I want to know the effects of others sending me large
>> values in a http post (not an image upload, but a form post).
>>
>> I'm assuming once it is sent by the client as a http post, and my servlet
>> responds to the request tomcat has already streamed that data and whether
>> I
>> do:
>>
>> String p1 = request.getParameter("big_**payload")
>>
>> or not, it has already been loaded into memory.
>>
>> Am I correct?
>>
>
> To me, it seems that Konstantin already answered those questions precisely
> and in detail below.
>
>
>
>> Is there a maximize size setting in tomcat?
>>
>> On Wed, Jan 4, 2012 at 1:03 PM, Konstantin Kolinko
>> wrote:
>>
>>  2012/1/4 S Ahmed :
>>>
>>>> Say I have a simple servlet or spring mvc application running on tomcat.
>>>>
>>>> Tomcat is running as a webserver on port 80.
>>>>
>>>> A client makes a http POST request to my page www.example.com/submit
>>>>
>>>> If the client adds a very large file with the POST, does this mean that
>>>> when my servlet code starts to execute, tomcat already has the entire
>>>> request content in memory? (including the very large POST parameter)
>>>>
>>> 1. Tomcat version =?
>>> 2. What API are you using to read the file?
>>>
>>> In general request processing starts after the headers in HTTP request
>>> have been read. At that point you can call getInputStream() and read
>>> the body of the POST request while it is being received from the
>>> client.
>>>
>>> But if you call certain APIs (e.g. getParameter()) the call will hang
>>> until entire POST request body is received from the client and
>>> processed. It is said that those methods "consume" the body of a POST
>>> request.
>>>
>>> 3. In most implementations large file uploads are not stored in
>>> memory, but are written to a temporary file on your hard drive. (So
>>> the request body is processed, but you cannot say that it is "in
>>> memory").
>>>
>>> --**--**
>>> -
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@tomcat.**apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>
>>>
>>>
>>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@tomcat.**apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: clarification on how data is streamed and handled by tomcat

2012-01-04 Thread S Ahmed
Tomcat 6
Spring MVC, where my controllers method has both httpservletrequest and
httpservletresponse as parameters.

The point is that I want to know the effects of others sending me large
values in a http post (not an image upload, but a form post).

I'm assuming once it is sent by the client as a http post, and my servlet
responds to the request tomcat has already streamed that data and whether I
do:

String p1 = request.getParameter("big_payload")

or not, it has already been loaded into memory.

Am I correct?

Is there a maximize size setting in tomcat?

On Wed, Jan 4, 2012 at 1:03 PM, Konstantin Kolinko
wrote:

> 2012/1/4 S Ahmed :
> > Say I have a simple servlet or spring mvc application running on tomcat.
> >
> > Tomcat is running as a webserver on port 80.
> >
> > A client makes a http POST request to my page www.example.com/submit
> >
> > If the client adds a very large file with the POST, does this mean that
> > when my servlet code starts to execute, tomcat already has the entire
> > request content in memory? (including the very large POST parameter)
>
> 1. Tomcat version =?
> 2. What API are you using to read the file?
>
> In general request processing starts after the headers in HTTP request
> have been read. At that point you can call getInputStream() and read
> the body of the POST request while it is being received from the
> client.
>
> But if you call certain APIs (e.g. getParameter()) the call will hang
> until entire POST request body is received from the client and
> processed. It is said that those methods "consume" the body of a POST
> request.
>
> 3. In most implementations large file uploads are not stored in
> memory, but are written to a temporary file on your hard drive. (So
> the request body is processed, but you cannot say that it is "in
> memory").
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


live redeploys and memory leaks

2011-12-30 Thread S Ahmed
If I have a running application, and I redeploy, is it possible to keep the
server live or does it have to shut-down and re-load?  Any gotchas with
doing this on a busy server?

Also, I have been reading that if you don't probably clean things up in a
web app, there is a strong possibility that the class loader will not be
destroyed when re-deploying and result in OOM errors potentially (if you
redeploy frequently etc.)  How can you avoid this situation?   Is the full
proof method to start/stop the tomcat service?


how can I figure out if tomcat is blocking and needs more threads? production tomcat monitoring tips.

2011-12-28 Thread S Ahmed
While benchmarking, I want to know if/when tomcat requires more threads
(maxThreads).

How can I figure this out?

i.e. I start benchmarking tomcat to see how it reacts to a high-traffic
spike, I want to make sure that tomcat isn't hitting the maxThreads when my
server has the ability resource wise.


Would jconsole be the only way?  Or will tomcat write to a log file also?
(so in a production setting I can scan my logs for these sort of
performance metrics etc.)

For production environments, how do you guys monitor tomcat? (for OOM,
hitting maxthreads limit, long GC cycles, etc.)


using htop, i see many tomcat processes?

2011-12-23 Thread S Ahmed
In my catalina.sh and set CATALINA_OPT, and I have Xmx around 2GB of ram.

When I run htop, I see many instances of the tomcat process.

I'm on a quad core server (xeon 3450), and I am seeing more than 15 tomcat
processes, and one of the columns shows how the process was started with
the java executable, and it shows Xmx 128m.

Can someone make sense of this to me? :)


where to put static files?

2011-11-20 Thread S Ahmed
I have a spring project (web app), in my project where should I be putting
my static files like images/css/javascript?

In my WEB-INF like:

/WEB-INF/Assets {images/css/js}


I know when I go in production I will have nginx map to this folder to
serve the static files, but I just want to know where I can put them for
development/testing.


multiple instances on a server

2010-08-27 Thread S Ahmed
Hi,

If you have a server with 15 GB of ram (or any large number for arguments
sake), does it ever make sense to run multiple instances of tomcat on the
same server?  (serving http requests for the same web application)

Or can a single instance utilize all the server resources just
fine efficiently?


The reason I am asking is that I have read that those hosting ruby on rails,
or python web applications usually run multiple instances of their
respective web server, each running on its own port, and then proxied using
haproxy or the like.