Hariharbalaji
Hariharbalaji

Reputation: 2578

Hibernate session connection relationship for Web application

I am a newbie for hibernate,

From the below link,

Hibernate Session Connection Relationship I understood that one hibernate session object will hold one connection object.

so my doubt is,if i have configured my connection pool size as 10 in my server. Will it be possible for only 10 people to work simultaneously in the application ?

Please correct me if i am wrong.

Upvotes: 1

Views: 327

Answers (2)

JB Nizet
JB Nizet

Reputation: 691635

That's right. But that doesn't limit the number of users to 10, because in a typical application, a user clicks on a link, which causes a connection to be used for a few milliseconds (the time to load the page), and then stares at the page for seconds or minutes.

So if the ratio of idle time vs. busy time is of 100 on average, you can expect to have 1000 users sharing the 10 connections in your pool, and everything should be fine (this is of course an approximation, that doesn't take bursts, long tasks, etc. into account, but you get the idea).

To sum it up: a connection is used by a user only during a transaction, which should very short (as short as possible). This is what makes many concurrent users possible.

Upvotes: 1

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340708

Partially, yes. This means only 10 SQL queries can be executed at the same time. If 11 clients are accessing the same page at exactly the same time and the majority of time is spent in some long-running SQL query then most likely the eleventh client will have to wait for one of the remaining 10 to finish.

However this does not mean your application is limited to 10 sessions/clients! For example in a web application the user typically opens a page, looks at it for a while, clicks on a link, etc. If your user spends 9 seconds reading the page and 1 second waiting for next page then only 10% of the time is spent on the server - hence you can handle 100 logged in users.

Moreover handling a request is not only about SQL queries. Sending data back and forth, parsing, rendering... - this all takes time.

So basically: you are limited to 10 concurrent SQL queries but this means 10x or maybe 100x more users that can use your application.

Upvotes: 2

Related Questions