473,698 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about database connections

Hi,

My hosting provider only allows me to use 50 connections to my MySQL
database that my Web site will use.

I don't know what this 50 connections means exactly. Does this mean that
only 50 visitors to my Web site can access my database through my Web site
at one time?

Or does this mean that in my code I can only use 50 connections? and like
have an identifier for each connection, like if I used persistant
connections?

Jul 17 '05 #1
3 2407
"Mudge" <ma******@hotma il.com> schrieb im Newsbeitrag
news:YF5Hc.4428 7$XM6.5528@attb i_s53...
Hi,

My hosting provider only allows me to use 50 connections to my MySQL
database that my Web site will use.

I don't know what this 50 connections means exactly. Does this mean that
only 50 visitors to my Web site can access my database through my Web site
at one time?

Or does this mean that in my code I can only use 50 connections? and like
have an identifier for each connection, like if I used persistant
connections?


I am not absolutely sure but I think it is your first point (50 connections
at a time). To be absolutely sure you might contact your provider's support
department.

--
Markus
Jul 17 '05 #2
>My hosting provider only allows me to use 50 connections to my MySQL
database that my Web site will use.
I presume that means 50 simultaneous connections max. This is what
MySQL can be set to enforce. A connection is in use while the PHP
page is executing (between the time you open and close the connection
or the page exits) or, if you use persistent connections, the
connection is more or less permanent but can be used by one page
running at a time.

Persistent connections can speed things up BUT you have to watch out
for a few things:

- "stale" connections: a page can sometimes get a stale or
"hosed-up" connection that turns out to be useless. For
example, the database timed out the connection for inactivity,
the database got switched on the connection and the new uses
didn't expect that, or the connection is left holding a lock
the new user doesn't know he's supposed to release.

- One cached persistent connection per Apache instance: in
Apache 1.3, each instance of Apache stores its own persistent
connection. If the max number of Apache instances working on
your site is over 50, expect problems. Persistent connections
can INCREASE the number of connections in use because Apache
instances can hold the connection while working on some other
page.

If you have 500 users simultaneously staring at your web page and
occasionally making queries, and the queries run fairly fast, you
probably won't get anywhere near 50 simultaneous connections.
They'll be spending most of their time reading the page, filling
in a query, or reading the answer, and relatively little time
reloading. This may not apply if a query usually takes several
minutes worth of database crunching to deliver an answer.
I don't know what this 50 connections means exactly. Does this mean that
only 50 visitors to my Web site can access my database through my Web site
at one time?
Roughly speaking, only 50 visitors can be LOADING the page at the
same time. And the loading time of non-PHP pages and graphics not
being run through a PHP page doesn't count. Note that if you DO
run graphics through PHP and use the database (sometimes done as
access control on pay sites or to try to prevent deep linking),
browsers often fetch multiple images in parallel, so you might end
up with several simultaneous connections from one guy with one
browser.
Or does this mean that in my code I can only use 50 connections? and like
have an identifier for each connection, like if I used persistant
connections?


If you need 50 database connections for one page, something's
seriously wrong, unless this is the "which databases are up and
which are down status page" which tests each of them every time it
loads. (and then it should be opening one connection, closing it,
and repeat, never using more than one at one time.) There are
occasionally uses for having two or more connections on the same
page. Usually that is done for programming convenience because it
is expected that one of the databases might switch servers while
the other one stays put. For a production, high-volume application
I'd try really hard to avoid doing this. For low-use administrative
maintenance pages, it's less of an issue. (I had one page that did
a side-by-side comparison of the OLD database and the NEW database
while a conversion was in progress, largely to detect problems with
the conversion before going live with it. That was essentially a
throw-away page and was used only by me to quickly locate problems.)

Tips to minimize simultaneous connections:

- Open the connection as late as possible and preferably avoid doing it
at all if it's not necessary.
- Explicitly close the connection as soon as possible.
- Close one connection before opening another (presumably to a different
server), if practical. Better yet, keep re-using the same connection.
- If practical, fetch the data first, close the database, THEN output the
page.
- Avoid, if possible, doing anything time-consuming, like retrieving
another page from another server, with the connection open.
- Persistent connections often make the simultaneous connections worse
while saving processing cost of tearing them down and re-creating them.
If you've got a lot of users and a low connection limit, avoid using
persistent connections. On the other hand if you're running out of CPU
first, maybe you're better off using them.

Gordon L. Burditt
Jul 17 '05 #3
Gordon Burditt wrote:
My hosting provider only allows me to use 50 connections to my MySQL
database that my Web site will use.


I presume that means 50 simultaneous connections max. This is what
MySQL can be set to enforce. A connection is in use while the PHP
page is executing (between the time you open and close the connection
or the page exits) or, if you use persistent connections, the
connection is more or less permanent but can be used by one page
running at a time.

Persistent connections can speed things up BUT you have to watch out
for a few things:

- "stale" connections: a page can sometimes get a stale or
"hosed-up" connection that turns out to be useless. For
example, the database timed out the connection for inactivity,
the database got switched on the connection and the new uses
didn't expect that, or the connection is left holding a lock
the new user doesn't know he's supposed to release.

- One cached persistent connection per Apache instance: in
Apache 1.3, each instance of Apache stores its own persistent
connection. If the max number of Apache instances working on
your site is over 50, expect problems. Persistent connections
can INCREASE the number of connections in use because Apache
instances can hold the connection while working on some other
page.

If you have 500 users simultaneously staring at your web page and
occasionally making queries, and the queries run fairly fast, you
probably won't get anywhere near 50 simultaneous connections.
They'll be spending most of their time reading the page, filling
in a query, or reading the answer, and relatively little time
reloading. This may not apply if a query usually takes several
minutes worth of database crunching to deliver an answer.
I don't know what this 50 connections means exactly. Does this mean that
only 50 visitors to my Web site can access my database through my Web site
at one time?


Roughly speaking, only 50 visitors can be LOADING the page at the
same time. And the loading time of non-PHP pages and graphics not
being run through a PHP page doesn't count. Note that if you DO
run graphics through PHP and use the database (sometimes done as
access control on pay sites or to try to prevent deep linking),
browsers often fetch multiple images in parallel, so you might end
up with several simultaneous connections from one guy with one
browser.
Or does this mean that in my code I can only use 50 connections? and like
have an identifier for each connection, like if I used persistant
connections ?


If you need 50 database connections for one page, something's
seriously wrong, unless this is the "which databases are up and
which are down status page" which tests each of them every time it
loads. (and then it should be opening one connection, closing it,
and repeat, never using more than one at one time.) There are
occasionally uses for having two or more connections on the same
page. Usually that is done for programming convenience because it
is expected that one of the databases might switch servers while
the other one stays put. For a production, high-volume application
I'd try really hard to avoid doing this. For low-use administrative
maintenance pages, it's less of an issue. (I had one page that did
a side-by-side comparison of the OLD database and the NEW database
while a conversion was in progress, largely to detect problems with
the conversion before going live with it. That was essentially a
throw-away page and was used only by me to quickly locate problems.)

Tips to minimize simultaneous connections:

- Open the connection as late as possible and preferably avoid doing it
at all if it's not necessary.
- Explicitly close the connection as soon as possible.
- Close one connection before opening another (presumably to a different
server), if practical. Better yet, keep re-using the same connection.
- If practical, fetch the data first, close the database, THEN output the
page.
- Avoid, if possible, doing anything time-consuming, like retrieving
another page from another server, with the connection open.
- Persistent connections often make the simultaneous connections worse
while saving processing cost of tearing them down and re-creating them.
If you've got a lot of users and a low connection limit, avoid using
persistent connections. On the other hand if you're running out of CPU
first, maybe you're better off using them.

Gordon L. Burditt


Thank you. This is very helpful. I've put this posting in my file for later
reference.

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2191
by: DW | last post by:
Greetings: I have a SQL 2000 server with several databases on it, and I have a maintenance plan that includes both a backup and a CHECKDB Integrity Check. The backups appear to run correctly each night, but if a user leaves a connection open to a database all night, the CHECKDB fails. I'd like to be able to kill all client connections before each backup
11
4260
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
4
1304
by: | last post by:
I was just wondering what other people's opinions and experiences were in regards to using Database Connections throughout a website. Supposing that a single webpage accesses a database anywhere from 5-30 times throughout a webpage do you prefer to open the database connection upon say initialization and reuse it elsewhere whenever possible and then dispose of it upon disposing or do you write 5 - 10 lines of code opening and closing it...
7
10588
by: Mark A | last post by:
If server 01 running HADR in the primary role crashes, and the DBA does a HADR takeover by force on the 02 server to switch roles, then the 02 server is now the primary. What happens when the Server 01 is brought back up? It still thinks it is the primary because that was its role when it crashed and it does not know about the takeover by force command that was issued. Does the 01 server check the 02 server to see what role they are in...
3
10291
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not available...)? Are there any strategies to detect this broken connections, and how can I
20
3281
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how many connection has been used ? 2. If the maximum pool size has been reached, what happens when I call the method Open to open the connection ? Will I get an error ? MSDN says the request is queued, but will I get an error in the open method ? ...
4
2462
by: kessa | last post by:
Hi Guys, I've recently had a problem with my site displaying a "system resources exceeded" error message ... and whilst searching this site for a solution (which I think I've now found) I came across mention of closing database connections and so had a "best practice" question which I hoped someone might be able to help me with? I'm a .asp newbie and much of what I have learnt has been done by looking at various snippets of code on the web...
5
5894
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to store a DataTable in any other way outside of our servers. In doing so, we leave ourselves open to large memory requirements. Furthermore, most web pages do not really support multiple changes per transaction. In other words, when the user submits...
2
1023
by: eric | last post by:
I have a legacy ISAM database on a customers server that I want to access from an ASP .NET powered web-site on a different server. The only communication method between the 2 must be tcp/ip, and the server where the database is located can only make outgoing connections (cannot accept connections). The database has no fancy access methods such as SQL, ODBC, OLEDB, or anything other than a native API which only includes basic functions...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.