Apache NOT responding

Forum for questions and support relating to the 1.24.x releases only.
johnnytolengo
Posts: 184
Joined: Tue Oct 14, 2008 5:59 pm

Post by johnnytolengo » Fri May 28, 2010 9:43 am

Hi, where I have to put this values in apache2.conf?

here my apache2.conf

Code: Select all

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "/var/log/apache2/foo.log"
# with ServerRoot set to "" will be interpreted by the
# server as "//var/log/apache2/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#<IfModule>
#<IfModule>
LockFile /var/lock/apache2/accept.lock
#</IfModule>
#</IfModule>

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
#KeepAliveTimeout 15
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
## 

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files>
    Order allow,deny
    Deny from all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog /var/log/apache2/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

#
# Define an access log for VirtualHosts that don't define their own logfile
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined


# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/
thanks.

jT.[/code]

jhetrick62
Posts: 24
Joined: Thu Jun 04, 2009 2:43 am

Post by jhetrick62 » Fri May 28, 2010 12:23 pm

I put them under the Prefork MPM module and modified those that were there, with the 4 that I listed. It seemed to help.

I'm not saying that it never froze after that, I think once, but it was much better. Doesn't freeze with IE 6 though using the Camboloza plugin.

Jeff

jhetrick62
Posts: 24
Joined: Thu Jun 04, 2009 2:43 am

Post by jhetrick62 » Fri Jun 04, 2010 5:35 pm

One other bit of wisdom, if I keep my zoneminder bandwidth set to Medium and NOT low, it rarely freezes although I did up WEB_M_AJAX_TIMEOUT to 10000 in the medium b/w settings.

Updated 6/13/10: I did narrow down some of the freezing problem further to latency in the browser connection! I was connecting primarily through a VPN tunnel to the remote site where the ZM server is. That was causing issues also. I now access it still on port 80 through a straight WAN connection and much better as long as I'm not on a wireless router, again my laptop on LOW B/W settings is ok sometimes, but freezes sometimes, but much improved as long as I stay out of the VPN tunnel.

I did add 1 other change that stablized it even further and that was to edit the "Paths" tab, setting for "Paths_ZMS" from /cgi-bin/nph-zms to /cgi-bin/zms. The non parsed headers daemon would freeze from the latency and run to 100% CPU. The straight zms settings has been fine with no freezes.

Overall, much, much improved so hopefully this entire thread will help someone else.

Maklaut
Posts: 7
Joined: Sun Jun 26, 2011 9:19 am

Re: Apache NOT responding

Post by Maklaut » Sun Jun 26, 2011 9:31 am

I found a solution.

All apache's processes was locked for flock() in session_start(). But one apache process (who was locking all other) was waiting for socket_select() in stream.php for a very long time.
This line:
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT );

This is because of MSG_TIMEOUT value was passed in ms (3000ms), but socket_select() treat four parameter as seconds (3000 seconds)!

I changed it like that:

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT/1000 );

Restarted apache. And now it's working fine.

PS my zoneminder version is 1.24.2-8ubuntu1

This bug still not fixed in the last svn revision (r3469) of stream.php.
Last edited by Maklaut on Sun Jun 26, 2011 3:55 pm, edited 1 time in total.

mastertheknife
Posts: 679
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: Apache NOT responding

Post by mastertheknife » Sun Jun 26, 2011 9:41 am

Interesting discovery! I will try that and report back. The hang issue is so annoying and requires me to restart apache often.

Thank you!
mastertheknife
Last edited by mastertheknife on Mon Jun 27, 2011 1:36 pm, edited 1 time in total.
Kfir Itzhak.

User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Re: Apache NOT responding

Post by Normando » Sun Jun 26, 2011 10:17 am

Thanks Maklaut for the fix. But this has a side effect the the status and fps is not updated. Use a value like 5 or 10 intead of 0.

from php manual:
int socket_select ( array &$read , array &$write , array &$except , int $tv_sec [, int $tv_usec = 0 ] )
The tv_sec and tv_usec together form the timeout parameter. The timeout is an upper bound on the amount of time elapsed before socket_select() return. tv_sec may be zero , causing socket_select() to return immediately. This is useful for polling. If tv_sec is NULL (no timeout), socket_select() can block indefinitely.

Maklaut
Posts: 7
Joined: Sun Jun 26, 2011 9:19 am

Re: Apache NOT responding

Post by Maklaut » Sun Jun 26, 2011 3:54 pm

Normando wrote:Thanks Maklaut for the fix. But this has a side effect the the status and fps is not updated. Use a value like 5 or 10 intead of 0.

from php manual:
int socket_select ( array &$read , array &$write , array &$except , int $tv_sec [, int $tv_usec = 0 ] )
The tv_sec and tv_usec together form the timeout parameter. The timeout is an upper bound on the amount of time elapsed before socket_select() return. tv_sec may be zero , causing socket_select() to return immediately. This is useful for polling. If tv_sec is NULL (no timeout), socket_select() can block indefinitely.
May be you are right. socket_select() description from php site is not clear for me. Now I change it this way:

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT/1000 );

User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Re: Apache NOT responding

Post by Normando » Sun Jun 26, 2011 5:58 pm

Maklaut wrote:
Normando wrote:Thanks Maklaut for the fix. But this has a side effect the the status and fps is not updated. Use a value like 5 or 10 intead of 0.

from php manual:
int socket_select ( array &$read , array &$write , array &$except , int $tv_sec [, int $tv_usec = 0 ] )
The tv_sec and tv_usec together form the timeout parameter. The timeout is an upper bound on the amount of time elapsed before socket_select() return. tv_sec may be zero , causing socket_select() to return immediately. This is useful for polling. If tv_sec is NULL (no timeout), socket_select() can block indefinitely.
May be you are right. socket_select() description from php site is not clear for me. Now I change it this way:

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT/1000 );
Exactly. If you put a zero, socket_select() return immediately and has no enought time to process the ajax request:
tv_sec may be zero , causing socket_select() to return immediately.
Your last modification is the real fix (MSG_TIMEOUT/1000).

mastertheknife
Posts: 679
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: Apache NOT responding

Post by mastertheknife » Sun Jun 26, 2011 8:44 pm

Normando wrote:
Exactly. If you put a zero, socket_select() return immediately and has no enought time to process the ajax request:
tv_sec may be zero , causing socket_select() to return immediately.
Your last modification is the real fix (MSG_TIMEOUT/1000).
I can confirm. Using the first fix resulted in monitor info\control (ajax code) not working. The second fix works well.

Thank you both, this is a good fix for a long-time annoying issue.
mastertheknife.
Kfir Itzhak.

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: Apache NOT responding

Post by zoneminder » Mon Jun 27, 2011 11:17 am

My reading of the docs indicates that doing

Code: Select all

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
should function as intended. Unless someone can persuade me that I have misunderstood I will update the code to do that, it seems to work ok for far.
Phil

mastertheknife
Posts: 679
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: Apache NOT responding

Post by mastertheknife » Mon Jun 27, 2011 11:31 am

zoneminder wrote:My reading of the docs indicates that doing

Code: Select all

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
should function as intended. Unless someone can persuade me that I have misunderstood I will update the code to do that, it seems to work ok for far.
Hi Phil,
This is clearly not the code in ZM 1.24.4. The code in ZM 1.24.4 is like this:

Code: Select all

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT );
The problem is that it seems to send the timeout in milliseconds, but the fourth parameter actually expects timeout in seconds.

P.S: have you read my PM? :D

mastertheknife.
Kfir Itzhak.

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: Apache NOT responding

Post by zoneminder » Mon Jun 27, 2011 11:37 am

mastertheknife wrote:
zoneminder wrote:My reading of the docs indicates that doing

Code: Select all

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
should function as intended. Unless someone can persuade me that I have misunderstood I will update the code to do that, it seems to work ok for far.
Hi Phil,
This is clearly not the code in ZM 1.24.4. The code in ZM 1.24.4 is like this:

Code: Select all

$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, MSG_TIMEOUT );
The problem is that it seems to send the timeout in milliseconds, but the fourth parameter actually expects timeout in seconds.
Yes, I understand that, I was proposing what it will be changed to, splitting the timeout in ms, into seconds and microseconds components before passing it to the select call.
mastertheknife wrote:P.S: have you read my PM?
Yes, but then forgot about it :oops: I'll get back to you now.
Phil

jhetrick62
Posts: 24
Joined: Thu Jun 04, 2009 2:43 am

Re: Apache NOT responding

Post by jhetrick62 » Mon Jun 27, 2011 11:45 am

I for one am very glad to see a solution to this issue as it has definitely been an annoying issue. Thank you very much for addressing an old problem!

User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Re: Apache NOT responding

Post by Normando » Mon Jun 27, 2011 2:24 pm

I agree Phill. So a MSG_TIMEOUT of "3500" miliseconds will be splited as this:
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, 3, 500000 );
I am right?

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: Apache NOT responding

Post by zoneminder » Mon Jun 27, 2011 3:17 pm

Yes. That's how I see it.
Phil

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests