Обсуждение: Open connections

Поиск
Список
Период
Сортировка

Open connections

От
"Nico"
Дата:
I would like to know how many connections are open at a certain time from a
servlet, so I can anticipate connection errors. How do I do that?

Nico.



Re: Open connections

От
Dave Cramer
Дата:
Nico,

this is somewhat problematic, the only way to do this is to use the unix
tool ps to determine the number of processes.

A much better way to do this is to use a robust connection pool like
dbcp from apache, which will manage your connections for you.

Dave

Nico wrote:

>I would like to know how many connections are open at a certain time from a
>servlet, so I can anticipate connection errors. How do I do that?
>
>Nico.
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly
>
>
>
>

--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561


Re: Open connections

От
"Nico"
Дата:
I forgot to mention one thing: I have no control over the server it's
running on. I only have permission for my account. It is imperative that I
can have 4 open connections with my database, since my servlet generates a
framesetpage where each frame of the three frames is that same servlet with
other parameters to connect to the same database. Most of the time it's not
a problem, but when I get 3 or more visitors at the same time, my
connections start to make trouble. Here is my website:
http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311

"Dave Cramer" <pg@fastcrypt.com> schreef in bericht
news:41D15B20.5000409@fastcrypt.com...
> Nico,
>
> this is somewhat problematic, the only way to do this is to use the unix
> tool ps to determine the number of processes.
>
> A much better way to do this is to use a robust connection pool like dbcp
> from apache, which will manage your connections for you.
>
> Dave
>
> Nico wrote:
>
>>I would like to know how many connections are open at a certain time from
>>a servlet, so I can anticipate connection errors. How do I do that?
>>
>>Nico.
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>      subscribe-nomail command to majordomo@postgresql.org so that your
>>      message can get through to the mailing list cleanly
>>
>>
>>
>
> --
> Dave Cramer
> http://www.postgresintl.com
> 519 939 0336
> ICQ#14675561
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org
>



Re: Open connections

От
Dave Cramer
Дата:
Nico,

I would still share the connections using a pooling mechanism of some kind. If every visitor is going to require 3 connections to the database, you can never scale past a certain point anyway.

Most of the time the connection is only required for a short period of time. ie request comes in, get the connection, get the result set, read the result set into beans, or objects,  return connection and then display.

This can be done with each frame/servlet

Dave

Nico wrote:
I forgot to mention one thing: I have no control over the server it's 
running on. I only have permission for my account. It is imperative that I 
can have 4 open connections with my database, since my servlet generates a 
framesetpage where each frame of the three frames is that same servlet with 
other parameters to connect to the same database. Most of the time it's not 
a problem, but when I get 3 or more visitors at the same time, my 
connections start to make trouble. Here is my website: 
http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311

"Dave Cramer" <pg@fastcrypt.com> schreef in bericht 
news:41D15B20.5000409@fastcrypt.com... 
Nico,

this is somewhat problematic, the only way to do this is to use the unix 
tool ps to determine the number of processes.

A much better way to do this is to use a robust connection pool like dbcp 
from apache, which will manage your connections for you.

Dave

Nico wrote:
   
I would like to know how many connections are open at a certain time from 
a servlet, so I can anticipate connection errors. How do I do that?

Nico.


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate    subscribe-nomail command to majordomo@postgresql.org so that your    message can get through to the mailing list cleanly


     
-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
             http://archives.postgresql.org
   


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command   (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

 

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561

Re: Open connections

От
Scott Marlowe
Дата:
On Tue, 2004-12-28 at 05:34, Nico wrote:
> I would like to know how many connections are open at a certain time from a
> servlet, so I can anticipate connection errors. How do I do that?

Assuming that stats_row_level = true is set in the postgresql.conf file,
you can find out with:

SELECT * from pg_stat_activity;


Re: Open connections

От
Kris Jurka
Дата:

On Tue, 28 Dec 2004, Scott Marlowe wrote:

> Assuming that stats_row_level = true is set in the postgresql.conf file,
> you can find out with:
>
> SELECT * from pg_stat_activity;
>

pg_stat_activity does not require row level stats.  To get the command
string in this view you need stats_command_string enabled, but again
that's not necessary to just see open connections.

This method doesn't seem like a real solution to the problem at hand
though.  How are you going to determine if you are allowed to make a
connection to the database?  By making a connection to the database and
querying this view?  Note also that the pg_stat_activity view lags reality
by up to a half a second.  Note also that the max_connections setting is
per cluster, not per database, so you cannot know or control what other
clients are going to do with other databases.

I would definitely consider a connection pool as others have
suggested and possibly moving away from frames entirely.

Kris Jurka

Re: Open connections

От
"Nico"
Дата:
That's where the next problem lies: I don't know anything about pooling mechanisms. Could you please give me a good place to get started? Or some code how to do so?
Thanks.
"Dave Cramer" <pg@fastcrypt.com> schreef in bericht news:41D16C5E.8010800@fastcrypt.com...
Nico,

I would still share the connections using a pooling mechanism of some kind. If every visitor is going to require 3 connections to the database, you can never scale past a certain point anyway.

Most of the time the connection is only required for a short period of time. ie request comes in, get the connection, get the result set, read the result set into beans, or objects,  return connection and then display.

This can be done with each frame/servlet

Dave

Nico wrote:
I forgot to mention one thing: I have no control over the server it's 
running on. I only have permission for my account. It is imperative that I 
can have 4 open connections with my database, since my servlet generates a 
framesetpage where each frame of the three frames is that same servlet with 
other parameters to connect to the same database. Most of the time it's not 
a problem, but when I get 3 or more visitors at the same time, my 
connections start to make trouble. Here is my website: 
http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311

"Dave Cramer" <pg@fastcrypt.com> schreef in bericht 
news:41D15B20.5000409@fastcrypt.com... 
Nico,

this is somewhat problematic, the only way to do this is to use the unix 
tool ps to determine the number of processes.

A much better way to do this is to use a robust connection pool like dbcp 
from apache, which will manage your connections for you.

Dave

Nico wrote:
   
I would like to know how many connections are open at a certain time from 
a servlet, so I can anticipate connection errors. How do I do that?

Nico.


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate    subscribe-nomail command to majordomo@postgresql.org so that your    message can get through to the mailing list cleanly


     
-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
             http://archives.postgresql.org
   


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command   (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

 

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561

Re: Open connections

От
Rupa Schomaker
Дата:
On 12/28/2004 3:35 PM, Nico wrote:
> That's where the next problem lies: I don't know anything about pooling
> mechanisms. Could you please give me a good place to get started? Or
> some code how to do so?
> Thanks.

The internet is a wonderful thing.  I think someone already pointed out
dbcp.

First, what web container are you using?  Nearly all come with a
connection pooling implementation.  Tomcat is bundled with dbcp.

Second, if you can't figure out the first, then just use dbcp:

http://jakarta.apache.org/commons/dbcp/

[snip]

> --
> Dave Cramer
> http://www.postgresintl.com
> 519 939 0336
> ICQ#14675561


--
 -Rupa


Re: Open connections

От
"Nico"
Дата:
Resin 3.0.8. Don't forget: I do not have permission to the resin
configuration files, only to my application files.
Nico.

"Rupa Schomaker" <pgsql-jdbc@lists.rupa.com> schreef in bericht
news:41D236C0.5090705@lists.rupa.com...
> On 12/28/2004 3:35 PM, Nico wrote:
>> That's where the next problem lies: I don't know anything about pooling
>> mechanisms. Could you please give me a good place to get started? Or
>> some code how to do so?
>> Thanks.
>
> The internet is a wonderful thing.  I think someone already pointed out
> dbcp.
>
> First, what web container are you using?  Nearly all come with a
> connection pooling implementation.  Tomcat is bundled with dbcp.
>
> Second, if you can't figure out the first, then just use dbcp:
>
> http://jakarta.apache.org/commons/dbcp/
>
> [snip]
>
>> --
>> Dave Cramer
>> http://www.postgresintl.com
>> 519 939 0336
>> ICQ#14675561
>
>
> --
> -Rupa
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly
>



Re: Open connections

От
"Rupa Schomaker (lists)"
Дата:
On 12/31/2004 8:08 AM, Nico wrote:
> Resin 3.0.8. Don't forget: I do not have permission to the resin
> configuration files, only to my application files.
> Nico.

Don't top post.

http://www.caucho.com/resin-3.0/features/overview.xtp#db

--
 -Rupa