When tuning Apache, remember to take into account the amount of RAM your SmartMachine contains, and the typical amount of RAM that all the processes on your SmartMachine consume.
The following table shows typical directives in /opt/local/etc/httpd/includes/mpm.conf for different sized SmartMachines to reduce the amount of RAM used on multiple requests:
If your site serves up a lot of static content, you may want to serve up that content from a separate light weight server such as Nginx or Lighttpd.
Always setup your databases on a separate SmartMachine. You can then setup the databases to connect to your Apache web servers through a private IP.
When running PHP with Apache you would want to enable an opcode cache so that PHP opcodes are not recompiled on each page request.
Apache is configured with a web based system status module that is very useful in getting the current status of your web server.
To enable mod_status you must SSH into your SmartMachine and become root:
1) Add these lines to the top of your Apache config file for the virtual server you want to monitor:
2) In the same config file add this location in the Virtual server after your cgi-bin declarations:
3) Restart your Apache server:
4) To view status from a web browser:
To have the page refresh ever 5 seconds:
To view from the command line:
Error on running out of file descriptors are recorded in your Apache error log. This normally is an issue with customer applications.
You can view what files are being used by Apache with the command:
How to check what you have set presently (as root or sudo)
Check to see if a project entry exists in /etc/project for httpd (as root or sudo)
If it does not exist (the command returns no result), then use projadd command to include an entry for apache
By default Apache comes with 1024 possible open files for each worker. This translates into 1024 ports which means your total maximum connections.
To increase the port limit:
You will reduce memory usage of Apache clients by binding the Server and VirtualHosts to a specific IP. Another way of saying this is not to use wildcard IP's ( * ):
You can do this by modifying the following files:
And change the existing entries to have the Apache server listen on the specific IP:
Uses less memory:
Uses more memory:
Also update your Virtualhost entries in:
Uses less memory:
Uses more memory:
If you are not using Phusion Passenger (for Ruby on Rails apps), you can safely comment out the lines to load the dso under /opt/local/etc/httpd/includes/dso.conf:
and /opt/local/etc/httpd/httpd.conf that loads the module:
There are many services that you can run to assist you in debugging and increasing the performance of your web application:
Install New Relic on your SmartMachine - it is free if you have a 1G or larger system and it provides so much information that we in Support can better assist you. Really, with the graphs and monitoring that they have allow you to quickly tell if it is code or database causing you issues.
Go there, set up your free account and install the client on your SmartMachines.
For PHP the Apache plugin APC can greatly reduce your apps load time by caching objects.
For database queries enabling MemCache can speed up database calls with caching.
Apache is great. However, it's full features may be more than what you need. You can dramatically increase performance of your SmartMachine and reduce your memory foot print by using a lightweight web server.
For example, here is an external article on how to setup and configure Ngnix on a Joyent SmartMachine: http://ecarmi.org/writing/setup-nginx-joyent-solaris-smartmachine/
<div class="tabletitle"> <a name="comments"> <h2>Comments:</h2> </a> </div> <table border="0" width="100%"> <tr> <td > <a name="comment-5144833"></a> <font class="smallfont"><p>The svccfg command gives 'Syntax error.'</p>
I think the correct command is:
svccfg -s http:apache setprop start/project = astring: httpd
svccfg -s apache setprop start/exec=astring: \"newtask -p httpd /opt/local/sbin/httpd -k start\"