Skip to Content.
Sympa Menu

freetds - Re: PHP, FreeTDS & Microsoft SQL Server 7, best methods?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Rasmus Lerdorf <rasmus AT raleigh.ibm.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: PHP, FreeTDS & Microsoft SQL Server 7, best methods?
  • Date: Fri, 3 Sep 1999 09:16:06 -0400 (Eastern Daylight Time)


> > The problem we're seeing at the moment, is despite the use of using
> > persistant
> > connections in our PHP/http pages, e.g. "sybase_pconnect()" - the machine
> > running PHP/Apache quickly seems to eat up all the connections available
> > to
> > our Microsoft SQL Server (10 in total).
> >
> I'm not sure what mechanism PHP uses to cache connections, but I do know
> that the dblib modules under PHP 3.0.x are somewhat of a mess. It looks
> like they been worked on under 4.0.

When PHP does a *_pconnect() it checks to see if a connection already
exists with the exact same set of connection parameters. db, username,
password, etc. This actual set is somewhat DB-dependant. If such a
connection exists, this connection handle is returned and this function
doesn't do anything else. This means that if you always connect to your
DB as the same user and everything else about your pconnect is constant,
you will eventually have the same number of persistant connections as you
have httpd processes. Setting MaxClient in your httpd.conf will therefore
effectively fix this number. There is also a sybase.max_links directive
in your php3.ini file that can limit this further. But, if you have many
more httpd processes than available connections, you lose most of the
benefits of persistent connections.

> > I've tried limiting the number of children Apache can have to only 3,
> > this has
> > helped a little - but it still runs out of connections.

This would indicate to me that you are connecting with different
connection parameters and thus each httpd child is maintaining multiple
connections. One thing I asked the MySQL guys for was a way to change the
connection parameters of an established connection on the fly. If this
could somehow be done in FreeTDS we might be able to improve a scenario
like this a bit. With Apache 2.0 going threaded in a hybrid manner,
things should also improve, assuming FreeTDS is thread-safe. In the
Apache 2.0 scenario you might configure 10 httpd processes and give each
10 threads. That way you would be able to handle 100 concurrent
connections sharing 10 persistent connections.

> > b) Are we using the best/most stable way of connecting PHP to a Microsoft
> > SQL
> > 7 server? - I'm looking to replace FreeTDS, but due to my lack of
> > understanding of it's components, are we using the best ones?

I have heard good things about Easysoft's ODBC bridge. See
www.easysoft.com. They have PHP-specific installation instructios as
well.

> I will test PHP persistant connects this weekend and see what I can find.
> Version information and a PHP script that replicates the problem would be
> most helpful.

Brian, I would be delighted to set you up with a CVS write account to the
PHP code repository so you can apply whatever changes/fixes you think are
needed. I would love to have PHP and FreeTDS working smoothly together
and getting FreeTDS to be the primary choice for all the people out there
that want to connect PHP to MS-SQL.

-Rasmus





Archive powered by MHonArc 2.6.24.

Top of Page