Q&A
Q1: | How can I measure whether my site is fast enough? |
A1: | Many developers test their sites locally or over an internal network, but if you run a public Web site, chances are good that many of your users will access it over slow links. Try navigating your Web site from a dialup account and make sure that your pages load fast enough, with the rule of thumb being that pages should load in less than three seconds. |
Q2: | How can I migrate an existing name-based virtual host to its own machine while maintaining continuous service? |
A2: | If a virtual host is destined to move to a neighboring machine, which by definition cannot have the same IP address, there are some extra measures to take. A common practice is to do something like the following, although many variations on these steps are possible:
|
Q3: | Can I mix IP- and name-based virtual hosting? |
A3: | Yes. If multiple IP addresses are bound, you can allocate their usage a number of different ways. A family of name-based virtual hosts might be associated with each; just use a separate NameVirtualHost directive for each IP. One IP might be dedicated as an IP-based virtual host for SSL, for instance, whereas another might be dedicated to a family of name-based virtual hosts. |
Quiz
1: | Name some Apache settings that might limit scalability or affect Apache performance. |
2: | Name some operating system settings that might limit scalability. |
3: | Name some approaches to improve performance. |
4: | Which VirtualHost container gets a request if the connection uses NameVirtualHost, but no Host header is sent? |
5: | Is the ServerName directive necessary in a VirtualHost container? |
Answers
A1: | Some of the Apache settings that might affect scalability include FollowSymLinks, SymLinksIfOwnerMatch arguments to the Options directive, enabling per-directory configuration files, hostname lookups, having a scoreboard file, and statistics collection with mod_status. |
A2: | Some operating system settings that might affect scalability include limits for number of processes, open file descriptors, and memory allowed per process. |
A3: | The following are some suggestions for improving performance: load distribution via a hardware load balancer or reverse proxy, data compression, caching, mapping files to memory, and compiling modules statically. |
A4: | Reading the configuration top-to-bottom, the first VirtualHost container is favored. The same behavior occurs if there is a Host header, but no VirtualHost container that matches it. |
A5: | Only when name-based virtual hosts are used. The Host header contents are compared to the contents of the ServerName directive. If a match isn't satisfied, the VirtualHost containers' ServerAlias directive value(s) are checked for matches. |