1

I've read many posts regarding Apache optimization. While reading, two names repeated over and over again, nginx and php-apc.

I've tried to understand which of them might be helpful for me, but i could not find a definite answer. I need my server to support about 10k connections. The server has 5GB of ram and 4 CPUs.

  1. My question is which of the both, if any, should I use?
  2. Do I need to change my code to better use of APC and nginx?
  3. Does using the nginx will remove any abilities from the web server?
  4. Am I missing anything? is there something basic that I have misses?

Apache info:

[root@web conf]# httpd -V
Server version: Apache/2.2.3
Server built:   Sep  3 2009 17:38:51
Server's Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -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=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Thanks!

EDIT

The site will be used for steaming video using flash-rtmp to steam the video and php (cake) and js for everything else.

Kuf
  • 449
  • 2
  • 8
  • 25

2 Answers2

3

apc acts as PHP module, wnile nginx is webserver and working with php via cgi interface. Shortly, web server configuration isn't an easy task and platform to choose depends on maany maany things. 10k connections - what does it mean, 10k parallel downloads? If video is delivered as files for same server - should be no problem with apache. better think about disk IO and networking, if you are processing video - i'm sure CPU cannot handle that. If you are running this php site to support video streaming, handled by the other server - probably there will be no massive php-related requests, so you can do it with anything, even without hard optimization.

My question is which of the both, if any, should I use?

  • You may use APC for any situation, but for nginx - depends. Nginx default configuration is more efficient than apache httpd, but after proper configuration, you might get almost same results with httpd.

Do I need to change my code to better use of APC and nginx?

  • For APC - it doesn't matter, when using nginx you will lose some additional features available in more common Apache httpd web server. Maybe you will need to fix something

Does using the nginx will remove any abilities from the web server?

  • Yes, many, the other question is if you use it

Am I missing anything? is there something basic that I have misses?

  • Current workload, where is bottleneck - CPU usage, networking, connections etc. APC will reduce CPU usage, increase RAM usage. http can be used with different models. As I see you've got RHEL5/Centos5 apache, 32-bit. At least, use relevant kernel (kernel-PAE) to use all 5GB of RAM. I won't recommend current apache model in your case (change model in /etc/sysconfig/httpd). You can use php as both module or via cgi (mod_fcgid).

This is far from the configuration details - there are many things to configure, including process respawn etc

GioMac
  • 4,544
  • 4
  • 27
  • 41
1

APC is a bytecode cache type affair for PHP, whereas nginx is a totally separate webserver. Might help to clarify what sort of sites you're planning to run.

Rasputnik
  • 196
  • 4
  • This is a video steaming site using flash-rtmp to steam the video and php (cake) and js for everything else. – Kuf Aug 05 '12 at 11:41
  • @Kuf Welcome to Server Fault. It's best to edit your original question to provide the requested clarifications, so that they can be found in the expected place. Information left in comments is easy to miss. – Michael Hampton Aug 05 '12 at 16:24