Number of RemoteDb connections active


i have a Sparkle Server, with different TRemoteDb modules added (about 20 different URL / db's).

There is already a way in Sparkle to know, at a certain moment, the total number of active connections ? Or i have to implement some sort of a thread-safe counter ?

If i do it this way, what do you think is the best place for the code that does the counter adding / subtracting 1  ? Maybe the Create / Destroy events of the TRemoteDb datamodules ?

Thank you


Hi Arnaldo,

What do you mean by "active connection"? The "problem" (actually a good thing) about RemoteDB is that unless you are using transactions (which should be short lived), the server is stateless. There is no "active connection". The next SQL execution requested from any client can be served by any database from the pool. So even though you might have 50 clients "connected" to RemoteDB server, there isn't necessarily 50 databases in the server, so you can't tell exactly how many clients you currently have.

Thank you Wagner, maybe i have some thing that i have misunderstood...

When a client application connect to the Sparkle server via TRemoteDb, the TRemoteDb module with the right URL is activated, and his TDbConnectionFactory is created. In my server, the ConnectionFactory creates a Datamodule. I thought that this operation would be one-to-one, so if i have 50 applications connected to Sparkle / TRemoteDbModule, i have also  50 datamodules created. Now, in my assumption, i would like to know how many datamodules i have in a certain moment.

I have to re-read the manual !


It is more or less like that, but suppose your client takes too long to perform another connection, the database in server will disappear. For the client it looks like it's still "connected" (a new SQL execution will create a new database in server), but in the server the database won't be there.

Having said that, we have plans to provide more statistical info from RemoteDB about the existing connections, databases, etc.. It will be available and won't take that long.

Thank you Wagner,

happy for the news, the statistics are something relevant (at least in my case !). Maybe it's because the servers in cloud are a bit pricey, and we always tend to "consume" entirely a server, before adding another....

Thanks again, have a good day