Zend/Apache2:多次请求URL时找到302 [英] Zend / Apache2: Getting 302 Found when requesting url several times

查看:87
本文介绍了Zend/Apache2:多次请求URL时找到302的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Zend框架编程 REST API .
当多次调用url(例如,每秒1000次,每秒请求1次)时,在大约 0.2%的情况下,而不是得到 200 OK 作为响应,我得到 302 Found -重定向到其他页面.
这是整个服务器的响应:

I am programming a REST API with Zend framework.
When calling the url several times (e.g. 1000 times with 1 request per second), in about 0.2 % of the cases instead of getting 200 OK as a response I get 302 Found - so a redirect to a different page.
Here is the entire server response:

302 Found Date: Mon, 04 Mar 2013 11:56:04 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.11
Set-Cookie: PHPSESSID=ui9r8jqa63dbom8osknso6eea5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: /de/default/index/index/error/500
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=utf-8

因此Zend重定向到错误500 (内部服务器错误)页面.问题是为什么-我只是想不通...
称为php的页面将一行插入到MySQL数据库中,并返回一个JSON字符串-就是这样.

So Zend redirects to the error 500 (internal server error) page. The question is why - and I just can't figure it out...
The php page that is called inserts one row into a MySQL database and returns a JSON string - that's all.

Apache2 已打开约 20个并发连接,服务器负载为<<< 1,所以我真的不明白为什么请求会导致问题.

Apache2 has about 20 concurrent connections open and the server load is <<1 so I really do not understand why the requests cause problems.

我知道这是一个非常难以诊断的远程诊断问题,但是非常欢迎提供很好的猜测和建议以解决此问题!谢谢.

这是@chris要求的apache虚拟主机配置:

This is the apache vhost config as requested by @chris:

<IfModule mod_ssl.c>
<VirtualHost mydomain.tld:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    ServerName www.mydomain.tld
    ServerAlias mydomain.tld *.mydomain.tld
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/ssl_access.log combined

#   RewriteLog "/var/log/htaccess.log"
#   RewriteLogLevel 5

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /etc/apache2/ssl/cert_2013_2014.crt
    SSLCertificateKeyFile /etc/apache2/ssl/www.mydomain.tld.key
    SSLCACertificateFile /etc/apache2/ssl/intermediate.crt

</VirtualHost>
</IfModule>

推荐答案

哇-那是一个完全出乎意料的问题,确实很难解决...

Wow - that was a totally unexpected problem and really hard to figure out...

@AdrianWorld帮助我走上了正确的道路.在Zend ErrorController中,我输出错误消息并发现以下异常:

@AdrianWorld helped me get on the right track. In the Zend ErrorController I output the error message and found the following exception:

ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) Array

这显然是描述和解决的非常普遍的问题

That apparently is a pretty common problem as described and solved here.
The variable session.gc_probability was set to 1 in the php.ini which means there is a 1% probability for the garbage collector to run and clean up the directory /var/lib/php5 where the php sessions are stored. Apparently this folder is not writable by www-data resulting in the mentioned error and throwing the Zend exception.

由于session.gc_probability仅设置错误随机发生的可能性,因此调试非常困难.

Since session.gc_probability sets only a probability the error occured randomly making debugging pretty difficult.

无论如何,我很高兴它已经解决-感谢所有的提示和猜测:)

Anyways, I'm happy it is solved - thanks for all the hints and guesses :)

这篇关于Zend/Apache2:多次请求URL时找到302的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆