Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7345 > unrolled thread
| Started by | Gilles <nospam@nospam.com> |
|---|---|
| First post | 2012-10-23 13:12 +0200 |
| Last post | 2012-10-25 13:04 +0200 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.php
[newbie] Small question about FastCGI Gilles <nospam@nospam.com> - 2012-10-23 13:12 +0200
Re: [newbie] Small question about FastCGI Jerry Stuckle <jstucklex@attglobal.net> - 2012-10-23 09:12 -0400
Re: [newbie] Small question about FastCGI Michael Vilain <vilain@NOspamcop.net> - 2012-10-23 22:06 -0700
Re: [newbie] Small question about FastCGI Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 20:49 +0200
Re: [newbie] Small question about FastCGI Gilles <nospam@nospam.com> - 2012-10-25 13:04 +0200
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2012-10-23 13:12 +0200 |
| Subject | [newbie] Small question about FastCGI |
| Message-ID | <0suc885dhh0buidnju0h77oqejlb8q22pa@4ax.com> |
Hello I just installed Lighttpd and mod_fastcgi to improve performance when running PHP scripts over CGI. Am I correct in understanding the following about what mod_fastcgi does: 1. loads severals instances of the PHP interpreter, each in its own process (hence the numerous instances of /usr/bin/php5-cgi in "ps aux" and the "php.socket-" pseudo-files in /tmp) 2. translates between HTTP requests/responses and the PHP scripts 3. does nothing about the PHP scripts, which are loaded, parsed, compiled, ran, and unloaded every time they are called ? I'm especially concerned about the last point: If I make a lot of calls to the database, does it mean that FastCGI doesn't provide persistent connections to it, so I'll have to investigate other ways to avoid opening/closing DB connections every time? Or is opening/closing DB connections a non-issue and the main issue is actual commands sent to the DB? Thank you.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-10-23 09:12 -0400 |
| Message-ID | <k66554$aet$1@dont-email.me> |
| In reply to | #7345 |
On 10/23/2012 7:12 AM, Gilles wrote: > Hello > > I just installed Lighttpd and mod_fastcgi to improve performance when > running PHP scripts over CGI. > > Am I correct in understanding the following about what mod_fastcgi > does: > 1. loads severals instances of the PHP interpreter, each in its own > process (hence the numerous instances of /usr/bin/php5-cgi in "ps aux" > and the "php.socket-" pseudo-files in /tmp) > 2. translates between HTTP requests/responses and the PHP scripts > 3. does nothing about the PHP scripts, which are loaded, parsed, > compiled, ran, and unloaded every time they are called > ? > > I'm especially concerned about the last point: If I make a lot of > calls to the database, does it mean that FastCGI doesn't provide > persistent connections to it, so I'll have to investigate other ways > to avoid opening/closing DB connections every time? Or is > opening/closing DB connections a non-issue and the main issue is > actual commands sent to the DB? > > Thank you. > Why do you think you need persistent connections? Do you have a performance problem you've traced down to connecting to the database? Persistent connections can improve performance in *very heavily* used websites (i.e. hundreds of hits per second), but also lock system resources even when the connections are not being used. In most cases persistent connections will have little or no impact on performance, and can actually degrade performance (as well as causing other problems like having left-over data from the previous usage of the connection). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Michael Vilain <vilain@NOspamcop.net> |
|---|---|
| Date | 2012-10-23 22:06 -0700 |
| Message-ID | <vilain-E975C6.22061923102012@news.individual.net> |
| In reply to | #7345 |
In article <0suc885dhh0buidnju0h77oqejlb8q22pa@4ax.com>, Gilles <nospam@nospam.com> wrote: > Hello > > I just installed Lighttpd and mod_fastcgi to improve performance when > running PHP scripts over CGI. > > Am I correct in understanding the following about what mod_fastcgi > does: > 1. loads severals instances of the PHP interpreter, each in its own > process (hence the numerous instances of /usr/bin/php5-cgi in "ps aux" > and the "php.socket-" pseudo-files in /tmp) > 2. translates between HTTP requests/responses and the PHP scripts > 3. does nothing about the PHP scripts, which are loaded, parsed, > compiled, ran, and unloaded every time they are called > ? > > I'm especially concerned about the last point: If I make a lot of > calls to the database, does it mean that FastCGI doesn't provide > persistent connections to it, so I'll have to investigate other ways > to avoid opening/closing DB connections every time? Or is > opening/closing DB connections a non-issue and the main issue is > actual commands sent to the DB? > > Thank you. According to http://php.net/manual/en/function.mysql-pconnect.php you can only do persistent connections with mod_php. This is because the apache server stays around and can reuse the mysql connection. With FastCGI, this doesn't happen. Apache forks php5-cgi which dies after the script is completed. Rethink your requirement for persistent database connections or use mod_php instead of FastCGI. -- DeeDee, don't press that button! DeeDee! NO! Dee... [I filter all Goggle Groups posts, so any reply may be automatically ignored]
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-10-24 20:49 +0200 |
| Message-ID | <64369903.lpGufVcNvk@PointedEars.de> |
| In reply to | #7348 |
Michael Vilain wrote:
> Gilles <nospam@nospam.com> wrote:
>> I just installed Lighttpd and mod_fastcgi to improve performance when
>> running PHP scripts over CGI.
>>
>> Am I correct in understanding the following about what mod_fastcgi
>> does:
>> 1. loads severals instances of the PHP interpreter, each in its own
>> process (hence the numerous instances of /usr/bin/php5-cgi in "ps aux"
>> and the "php.socket-" pseudo-files in /tmp)
>> 2. translates between HTTP requests/responses and the PHP scripts
>> 3. does nothing about the PHP scripts, which are loaded, parsed,
>> compiled, ran, and unloaded every time they are called
>> ?
>>
>> I'm especially concerned about the last point: If I make a lot of
>> calls to the database, does it mean that FastCGI doesn't provide
>> persistent connections to it, so I'll have to investigate other ways
>> to avoid opening/closing DB connections every time? Or is
>> opening/closing DB connections a non-issue and the main issue is
>> actual commands sent to the DB?
>>
>> Thank you.
>
> According to http://php.net/manual/en/function.mysql-pconnect.php you
> can only do persistent connections with mod_php.
You did read there "Use of this extension is discouraged", did you not?
> This is because the apache server stays around and can reuse the mysql
> connection.
Do you read what you reply to? The OP is not using Apache, they are using
Lighthttpd.
> With FastCGI, this doesn't happen. Apache forks php5-cgi
> which dies after the script is completed.
No, "FastCGI uses persistent processes to handle a series of requests."
They are not owned by the web server, but by the FastCGI server. [1]
> Rethink your requirement for persistent database connections or use
> mod_php instead of FastCGI.
Or maybe you want to get yourself informed before you give advice?
[1] <http://en.wikipedia.org/wiki/FastCGI> pp.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[toc] | [prev] | [next] | [standalone]
| From | Gilles <nospam@nospam.com> |
|---|---|
| Date | 2012-10-25 13:04 +0200 |
| Message-ID | <c47i88tmb5p899epudt92re7hrnlsqq6nr@4ax.com> |
| In reply to | #7351 |
On Wed, 24 Oct 2012 20:49:19 +0200, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: >No, "FastCGI uses persistent processes to handle a series of requests." >They are not owned by the web server, but by the FastCGI server. [1] Thanks for the info.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web