FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » [newbie] Small question about FastCGI
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
[newbie] Small question about FastCGI [message #179412] Tue, 23 October 2012 07:12 Go to next message
Gilles Ganault is currently offline  Gilles Ganault
Messages: 27
Registered: September 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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.
Re: [newbie] Small question about FastCGI [message #179414 is a reply to message #179412] Tue, 23 October 2012 09:12 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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(at)attglobal(dot)net
==================
Re: [newbie] Small question about FastCGI [message #179415 is a reply to message #179412] Wed, 24 October 2012 01:06 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
add to buddy list
ignore all messages by this user
In article <0suc885dhh0buidnju0h77oqejlb8q22pa(at)4ax(dot)com>,
Gilles <nospam(at)nospam(dot)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]
Re: [newbie] Small question about FastCGI [message #179418 is a reply to message #179415] Wed, 24 October 2012 14:49 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Michael Vilain wrote:

> Gilles <nospam(at)nospam(dot)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
Re: [newbie] Small question about FastCGI [message #179422 is a reply to message #179418] Thu, 25 October 2012 07:04 Go to previous message
Gilles Ganault is currently offline  Gilles Ganault
Messages: 27
Registered: September 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
On Wed, 24 Oct 2012 20:49:19 +0200, Thomas 'PointedEars' Lahn
<PointedEars(at)web(dot)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.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Setup help for PHP 64bit binaries
Next Topic: trouble with php5 ( while phpmyadmin works)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Oct 20 13:48:57 EDT 2017

Total time taken to generate the page: 0.00896 seconds