【发布时间】:2018-04-16 08:35:36
【问题描述】:
问题:
如何知道我的 apache 服务器是否已经在多进程和多线程模式下运行? 因为当我对其进行负载测试时,它给了我相同的结果时间和不同的线程数。我用 25 个线程和 50 个线程运行测试。
对于多线程/多进程的工作,我需要在 Django 代码中做任何调整吗?
我必须更改 MPM 配置 (/conf/extra/httpd-mpm.conf) 吗?
以下是我的服务器详细信息和配置:
Server redhat enterprise 6.9
Apache server 2.4.33
Postgre 9.6.6
Python 3.6
Virtualbox RAM 8Gb, 2 Core (4 vCpu).
我的 httpd.conf :
Listen 8000
LoadModule wsgi_module modules/mod_wsgi.so
Include conf/extra/httpd-vhosts.conf
WSGIScriptAlias / /home/applmgr/Harpa/HarpaBackend/harpa/wsgi.py
WSGIPythonHome /home/applmgr/Harpa/pyenv_sl
WSGIPythonPath /home/applmgr/Harpa/HarpaBackend
WSGIPassAuthorization On
<Directory /home/applmgr/Harpa/HarpaBackend/harpa>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
我的 httpd-vhosts.conf :
<VirtualHost *:8000>
Alias /static /home/applmgr/Harpa/HarpaBackend/static
<Directory /home/applmgr/Harpa/HarpaBackend/static>
Require all granted
</Directory>
WSGIDaemonProcess harpa python-home=/home/applmgr/Harpa/pyenv_sl processes=15 threads=50 python-path=/home/applmgr/Harpa/HarpaBackend
WSGIProcessGroup harpa
<Directory /home/applmgr/Harpa/HarpaBackend/harpa>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
ps -ef | grep httpd:
applmgr 2817 1 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2818 2817 0 14:18 ? 00:00:04 /opt/apache_http/bin/httpd -k start
applmgr 2819 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2820 2817 0 14:18 ? 00:00:03 /opt/apache_http/bin/httpd -k start
applmgr 2821 2817 0 14:18 ? 00:00:06 /opt/apache_http/bin/httpd -k start
applmgr 2822 2817 0 14:18 ? 00:00:03 /opt/apache_http/bin/httpd -k start
applmgr 2823 2817 26 14:18 ? 00:34:21 /opt/apache_http/bin/httpd -k start
applmgr 2824 2817 0 14:18 ? 00:00:06 /opt/apache_http/bin/httpd -k start
applmgr 2825 2817 47 14:18 ? 01:01:16 /opt/apache_http/bin/httpd -k start
applmgr 2826 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2827 2817 25 14:18 ? 00:33:00 /opt/apache_http/bin/httpd -k start
applmgr 2828 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2829 2817 0 14:18 ? 00:00:03 /opt/apache_http/bin/httpd -k start
applmgr 2830 2817 0 14:18 ? 00:00:03 /opt/apache_http/bin/httpd -k start
applmgr 2831 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2832 2817 0 14:18 ? 00:00:03 /opt/apache_http/bin/httpd -k start
applmgr 2833 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2834 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 2835 2817 0 14:18 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 3875 2817 0 14:23 ? 00:00:00 /opt/apache_http/bin/httpd -k start
applmgr 4979 2642 0 16:26 pts/1 00:00:00 grep httpd
./apachectl -V :
Server version: Apache/2.4.33 (Unix)
Server built: Apr 9 2018 16:42:03
Server's Module Magic Number: 20120211:76
Server loaded: APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/opt/apache_http"
-D SUEXEC_BIN="/opt/apache_http/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
【问题讨论】:
-
这是非常多的线程和进程,是的,您确实需要为您的设置修改 MPM 集。从阅读这方面的一些文档开始; garron.me/en/blog/apache2-mpm-worker-prefork-php.html
-
这不仅仅是 MPM 设置,使用这些设置实际上会使事情变得更糟。在 mod_wsgi 中,最好依赖守护程序模式,OP 是什么,以及如何配置进程/线程与 MPM 设置分开。
-
@markwalker_ 谢谢,我会查看该文档。
标签: django multithreading apache mod-wsgi