Web Tool Bag
Home · Articles · Downloads · Discussion Forum · Web Links · News Categories · Hosting information · Hosting ArticlesJanuary 06 2009 16:19:17
Navigation
Home
Articles
Downloads
Discussion Forum
Web Links
News Categories
Contact Me
Search
Site Partners
Users Online
Guests Online: 1
No Members Online

Registered Members: 125
Newest Member: Walter_Rowbotham36c41
viagra joke download us licensed pharmacies ketamine valium phentermine discount on-line no prescription best generic ultram cheap phentermine and xanax ambien long term side effects tramadol medication weight loss medicine meridia buy line viagra where danger of ambien cialis with purple pill paxil cr tablets paxil cr online from dreampharmaceuticals phentermine 37.5mg 90 pills ativan and flexeril tramadol serotonin dopamine buy cheap valium tramadol 58 93 generic phentermine india order ultram with out a prescription buy cheap discounted tramadol 20mg of ambien pharm phentermine buying viagra uk tramadol and flushed feeling order ambien from canada cheap phentermine about cheap phentermine mexico pharmacy ambien weight loss meridia lorazepam anxiety attack sleep insomnia picture of the pill viagra cheap cheap deal pill viagra viagra perscription drug stores ultram tramadol cheap ambien no prescription klonopin vers xanax can ambien cause a stroke zovirax pills pfizer sildenafil viagra counterfeit lorazepam effect phentermine 30mg blue no prescription viagra pulminary hypertension sildenafil citrate lowest cheap phentermine with no physician approval drug know maker need xanax ambien and breast pain tramadol detect urinalysis side effects of ultram free shipping on tramadol orders tramadol diazepam no prior prescription overnight delivery lunesta vs ambien soft pill cialis online and phentermine and cod pharmacy degree line buy tramadol cheap cod fedex tramadol very wellbutrin adhd phentermine sold without a prescription generic finasteride propecia order tadalafil and online fluconazole and alprazolam green white capsules phentermine phentermine drug indications buy xanax cheap medic affect phentermine side online pharmacy diflucan and clonazepam celecoxib and mesothelioma anaerobic infection atrophic rhinitis zithromax cod prozac cheap prednisone muscle weakness my fioricet fiorcet migraine is ambien gluten free cialis fee online cheapest xanax online female viagra alternate what is soma the drug nextday tramadol cash on deliver cod generic viagra money order weight loss and celexa withdrawal viagra online pharmacies glucophage help ovulation ambien as a date rape drug tramadol and kidneys weight glucophage hrt phentermine discount 30 mg phentermine 2737 amerimedrx herpes nexium zyban meridia better than phentermine meridia xenical and phentermine where to buy viagra ativan off re phentermine prescription viagra dosage 100mg cialis consultation delivery discount health man wellbutrin and lorazepam viagra sale pharmacy online cheap viagra new zealand buy xanax online us pharmacy picture of phentermine 37.5 12.5 ambien cr drug generic online pharmacy wellbutrin zyban wellbutrin information sildenafil viagra tablets bei hf6rsturz sildenafil viagra no presrciption what generic xanax look like lorazepam trip by glucophage generic equivalent of ambien lorazepam ld50 crushing tramadol for quick release cash on delivery fioricet mp 58 soma ambien sulfa diazepam no prescription next day delivery does ambien increase testosterone soma cubes phentermine scripts online herbal supplement contains sildenafil citrate adipex effects harmful side xanax grapefruit juice interaction phentermine hpen fen no dr required buring levitra online viagra baby what is best viagra cialis overnight phentermine no prescription hair loss and wellbutrin ambien bovine danger in using ambien viagra versus cialis espa ol viagra online canadiain effects of ambien on fetus what color is ambien acxess cialis usa mail buy sublingual cialis online sildenafil citrate us overnight delivery cheap phentermine 37.5mg buy tadalafil prescription medicine levitra duration of action ordering cheap phentermine cod cialis tadalafil canadian ultram more drug side effects metformin glucophage buy sildenafil citrate for sale online pharmacy overnight ativan 1mg finasteride propecia is tramadol a narcotic phentermine phentermine abuse eye from hemorrhage paxil phentermine and soma online pharmacy soma drug interaction tramadol seizures no script for cheap phentermine pliva tramadol buy keflex online can you get high on tramadol fosamax cancer splitting viagra 100 mg cheap online genric ambien buy evista cheap canada ambien levitra versus viagra tramadol as antidepressant search for fioricet when is valium perscribed ambien sleep pill atenolol fatigue generic meridia 10 mg discount hepsera hydrocodone soma wellbutrin allergic reaction pain medication tramadol fosamax weight loss side effects wellbutrin paxil valium accuretic ambien causing brain tumors add adult strattera vs wellbutrin appetite suppression drug sibutramine meridia phentermine levitra doseage order propecia pill atavan ativan tramadol drug guide order tadalafil canada online no rx cheap phentermine tramadol effects on dogs zoloft and valium together paxil or lexapro mix diazepam and vicoden avodart ciales clomid diflucan dostinex glucophage buy phentermine online without prescription cheap weight gain wellbutrin lexapro next day ambien adipex p lawsuits cialis the new viagra ativan withdrawl medical breakthrough of 1998 viagra diazepam experiment tramadol 100 er description id foreign phentermine pill sildenafil citrate tabletes buy phentermine costa rica buy viagra online in the uk viagra soft tabs next day buy xanax amex buy canadian prozac online danger levitra lexapro and xanax phentermine cod pharmacy online line tramadol cialis online from dreampharmaceuticals vrx v herbal viagra false positive for tramadol cheap soma usa tramadol and menstrual cycles tramadol cloridrato best herbal viagra viagra buy lamisil online generic cialis pills free sample tramadol and money order fluoxetine and norco fosamax weekly dose buy tramadol online pharmacy online online pharmacy phentermine xenical meridia ambien ativan klonopin dosage withdrawl detox diabetic diet vegetarian phentermine pill prescription drugs ambien free sample paxil and nursing buy xanax prescription require cheap phentermine through lighthouse phentermine yellow low dose prednisone low nexium price dysfunction erectile viagra alprazolam food effect valium stage fright interview generic viagra listings tramadol naproxin buy propecia online consultation lowest price tetracycline acne generic cialis soft viagra teddy bear phentermine no prescription 32 lorazepam for anxiety offender sex viagra buying viagra in canada ambien and price pharmacy online buy fioricet diazepam prilosec weight loss drugs phentermine clonazepam valium phentermine shipping celexa discount pharmacy purchase mixing ambien and vicodin cheap viagra pills buying phentermine without a prescription viagra online description chemistry ingredients sildenafil safe viagra alternatives switch from celexa to effexor ambien sleep talking find viagra free online search a buy phentermine online between difference levitra viagra glyburide metformin ambien online cheap phentermine discounts lexapro cause weight nexium delayed release capsule identify generic xanax phentermine free consultation no prescription addictive diazepam valium and alprazolam xanax fluoxetine hydrochloride as treatment information about danger of taking phentermine buy tramadol with paypal nexium online no prescription viagra and money order 5citrate generic sildenafil viagra 100 no prescription phentermine no topomax neurontin ritalin prozac ambien safe dose 5 sildenafil citrate warnings 67 flomax fluoxetine prescription writing for diazepam furosemide wellbutrin xl muscle relaxer drugs soma bontril xanax ambien day use cold sore valtrex mexican jumping bean viagra paxil pharmacy no prescription 1mg ativan vs xanax 0.5mg diazepam 2mg effects lowest price on phentermine 37.5 tetracycline antibiotic phentermine online overseas overnight express delivery generic cialis diet levitra ativan pdr diazepam drug information viagra perscription levitra drug cialis lawyer columbus ambien side effects tinnitus buy phentermine online u s pharmacy generic cialis pills doses discount online propecia lowest price phentermine gt can viagra delay ejaculation phentermine 37 5mg california ortho specialists newport beach ca buying phentermine with a money order tramadol recreational dose danger zithromax long term and liver viagra cll buy phentermine overnight online tramadol and depression meridia diet aie prednisone tablets side effects xanax xr generic ambien generic substitute soma discount code chicos generic ambien price crushing fosamax physical properties sildenafil citrate phentermine 90 pills no prescription buy tramadol where phentermine differences in pills info on tramadol living performance anxiety viagra propecia generic brand weight loss no prescription meridia western health levitra coverage tramadol 2bonline free tramadol delivery bontril ultram generic zanaflex cheap no prescription viagra order valium online drinking alcohol tramadol tramadol inducing withdrawl meridia cheap from india paxil pe online ambien zolpidem tartrate buy phentermine blue white capsuls online wellbutrin sr bupropion massachusetts christian cialis where can i buy phentermine cod synthroid more drug side effects xanax versus klonopin for chronic anxiety phentermine no prescription us pharmacy cheap ambien discount online pharmacy ambien table prednisone long term phentermine hcl diet pills dream online order pharmaceutical soma prevent effexor withdrawal with prozac discount valtrex fosamax 70 mg weekly phentermine hcl safe to take tramadol rls plmd iv iv sample viagra cheap evista online 6generic propecia alternative ambien cause numbness famvir buy prescription online valtrex viarga phentermine without prescription foreign online pharmacies lexapro xanax drug levitra viagra vs ambien rock opera mexican generic cialis trazadone and prozac interaction 180 cheap tramadol ativan drug interaction viagra erection attorneys dui ambien acyclovir 400 mg tablets order viagra buying viagra uk buy tetracycline no prescription valium shipped in u s fioricet drug phentermine tablets no rx buy phentermine online medipharm nexium discount permanent side effects ambien ambien and beer don't mix cut viagra pill ambien dose where can i buy cialis does herbal phentermine work gt generic overnight viagra pregnancy safety diazepam loss meridia pill weight switching from lexapro to zoloft online search tramadol cheap evista online cheap weight loss with paxil fda-approved prescribing ambien what type of medication is glucophage taking 5htp with prozac buy ambien without prescription information on cialis for erectile disfuntion ambien dreams online valium no prescriptions alternate uses for acyclovir tramadol drug medication tramadol cheap overnight inexpensive buy cialis dreampharmaceuticals online sildenafil chronic lung disease ambien shape buy viagra online u ambien cheapest paxil lawsuit canada plavix and cialis taken together what is metformin cheap adipex online cheap i us phentermine very buy fluoxetine hydrochloride india lorazepam seizure prophylaxis by dhl fioricet shipped overnight shipping phentermine without prescription phentermine 37.5 mg without primary doctor phentermine in stock overnight oxycontin taken with xanax sibutramine meridia and orlistat xenical generic viagra drugstore india lorazepam images diazepam manufacturer meridia buy without prescription phentermine 30mg without doctor prescription ambien side effects pulmonary tight chest ambien day next online drug soma manufacturer ultracet with aspirin lethal dose for lorazepam does it long paxil take work order viagra or levitra ambien yellow pills aciphex phentermine alprazolam online pharmacy cheap source viagra buy lexapro cheap ndice keflex oral soft tabs viagra canadian pharmacy for phentermine fentanyl patch and ultracet weight gain due to ambien lexapro more drug interactionslipitor dosage paxil lorazepam 1mg images pill splitter cialis glucophage tablets cheap genaric tramadol mix maxalt and valium cialis cost viagra pills online pharmacy 2b soma 100 mg tramadol what is chemical formula of tramadol no prior perscription tramadol health viagra woman ambien dangers tramadol drop drug tramadol ultram acid indigestion tramadol wetrack it fioricet 40 mg discount buy cialis doctor online 90 pills phentermine under 100.00 is klonopin or xanax better cheap online sales viagra ativan and celexa reactions buy cialis tadalafil at horizon drugs levitra online prescription augmentin side effects generic xanax 5 picture 1 meridia online contraindications information overdose tramadol ultracet buy tramadol online meridia pharmacy what is fioricet butalbital apap generic cialis uk fluoxetine drug info 10 panel drug tests and alprazolam fosamax osteonecrosis ambien and expire help vicoden effexor soma lexapro buying viagra in the united kingdom generic celexa problems viagra free gratis soma medication in florida tramadol for sale without a presription buy phentermine from study trial erope paxil weight loss tips prednisone weaning 37.5 mg phentermine tab cheap tramadol cod cheap valium with no rx canadian pharmacy for viagra when did prozac go generic uk viagra supplier side effects to ambien phentermine us pharmacy consultation xanax lortab adipex impurity related substance viagra depakote with tramadol take phentermine with xen soma on line cheap 6 finax hair loss generic propecia order finasteride online order phentermine safe viagra woman ambien articles cheap deal deal pill viagra viagra best quality lowest prices generic viagra available wellbutrin zyban difference cheap celecoxib buy phentermine 37.5 mgs morphine tramadol dosage equivalent tramadol dog dose tramadol cheap overseas fosamax mice thyroid difference between niravam xanax and alprazolam prednisone side effects in cats deal free viagra viagra free consultation us prednisone side effects in dog ambien overdose amount cheap no phentermine prescription required online catalog buy phentermine buy cheap xenical ambien and sinus smell discount phentermine 100 viagra ans levitra risk chest pain atenolol bush valium images of phentermine diet pills cialis wholesale online nexium drug tramadol and gos phentermine phentermine successful stories online pharmacy pill soma u s viagra buying phentermine online us licensed pharmacies leathal dose ambien information phentermine shortage ambien class action law suit viagra femenino cheap phentermine for sale cheap gerneric viagra valium equivalents for lorazepam 92 accepted cod phentermine mood disorder nos and prozac diet pill phentermine 37.5 meridia 15mg buy cheap cheap phentermine shipped by fedex buy viagra $8 per pill xanax and hydrocodone tadalafil vs generic viagra pill tramadol 180 ct tramadol cod delivery diazepam medication sildenafil and steroid use ativan generic lorazepam online soma drug information school finance what is tramadol discounted adipex meridia drug interaction cheap 15mg of meridia is lorazepam a truth serum inventor of lorazepam wyeth no rx phentermine 37.5 90 150 fioricet dosage ambien looks like ambien skin crawling phentermine to order weaning from ambien female free sample viagra minoxidil propecia phentermine online pharmacy's snorted valium buy cheap free online viagra viagra osteoporosis fosamax glucosamine glucophage pregnancy dose prozac impotence pill viagra phentermine fast no prescription nexium online phentermine 37.5mg no perscription fioricet medicine coupons ativan online no prescription articles about ambien cr phentermine no prescription fed-ex day where to puchase cialis online diazepam makes me depressed chlorhydrate de tramadol ingredients in phentermine original phentermine no rx diazepam dose in dogs phentermine adipex no prescripton necessary klonopin review rating xanax adipex buy online phentermine xanax cheap mexico buy tadalafil medicine online ambien fibromyalgia taking xanax lamisil and zoloft drugs tramadol ultram online diazepam no prescription meridia success pain meds and viagra is generic propecia fda approved sibutramin and phentermine and orlistat canadian pharmacy cialis deals cheap viagra nz recreation use of tramadol diazepam and gaba buy lexapro news imprint codes for tramadol medication pill ambien cr how supplied generic cialis pills levitra cialis generic versus brand name side effects of evista and fortical order tadalafil mexico online diazepam ip but phentermine without prescription soma conference san diego cheap soma canada buy generic ambien online drug fosamax osteoporosis treatment diet drug manufacturer meridia order phentermine free consultation buy viagra ambien 2baddiction tramadol chlorhydrate supply price history of valium buy ambien cr no rx finasteride vs dutasteride for steroids famvir zovirax valtrex phentermine diet pills no precription required tadalafil cialis from india cialis bestellen soma 350 flexeril meridia 10mg buy descrition of ambien cr buy 37.5 phentermine ambien cr while pregnant celexa and pregnancy glucophage buy diazepam from us pharmacy lorazepam 1mg picture buy cheap fioricet prescription nexium side effects phentermine with no prescription needed metformin insulin resista side effects if tetracycline vs sumycin foreign pharmacy buy hydrocodone xanax diet phentermine pill official store ups next day air tramadol celexa side effects 5cheapest sildenafil citrate alprazolam buy or xanax tramadol cod 50 states best buy deal online viagra viagra action ambien class suit lorazepam long acting benzodiazepine tramadol lead investigator viagra on-line drug testing ultram interaction tramadol and dalmane can glucophage cause a delayed period nursing article on ativan are ambien and tylenol safe together herbal i viagra is levitra as good as viagra cheap cod online sold tramadol celexa order online ambien patent expired cheap online viagra viagra viagra ultracet tab does paxil cause weight loss cheap diazepam 32 dream online pharmaceutical propecia hypertension pulmonar y sildenafil order phentermine online without perscription pharmacy cialis silagra fioricet migraine treatment ativan or xanax diazepam valium fedex online lorazepam and pregnancy buy ambien overnight what does viagra pill look like lamina propecia buy tramadol cod synthroid effect of fasting blood glucose klonopin to replace ativan klonopin rating xanax hycrococone phentermine viagra online in united states tramadol consult ambien where to buy ambien ambulance picture of viagra bottle tramadol proper doses for dogs phentermine no prescription 90 day order phentermine ativan by phone calcium fosamax asthma prednisone fosamax and teeth phentermine education genuine ham percussor reflex viagra what does viagra do to females buy generic cialis uk fioricet delivery on saturday buy adipex without prescription phentermine u s online physician how to go off paxil cialis zestril interactions lorazepam discovery free levitra sample discount phentermine blue phentermine no prescription online wellbutrin xl online headaches and migraine tramadol buy sildenafil citrate rxonline cialis pharmacy paxil viagra patanol online drug stores metrogel buy phentermine without a doctor's prescription
Performance-tuning Apache

Performance-tuning Apache

Introduction

This paper is intended as a guideline to performance-tuning the Apache HTTP Server software, and specifically on UNIX systems. The knowledge is that gathered while developing and maintaining a variety of websites for a large Dutch ISP, XS4ALL. While many of the concepts apply to Windows and other architectures as well, the details may very well differ. Some of the modules discussed (like mod_bandwidth) are not available on Windows. This paper assumes decent knowledge of installing and configuring Apache, UNIX systems and networking in general.

Performance-tuning is something that can require a lot of work. The basic most rule for any kind of optimization or tuning is "if it ain't broken, don't fix it." If Apache is performing just fine, there is no reason to possibly ruin the running configuration by trying to optimize it. Due to the modular design of Apache, most of the actual tuning is done by making trade-offs, trading features (possibly unused) for performance.

Another thing to note is that performance-tuning does not necessarily mean optimizing for speed. The goal of the exercise is to make Apache use its resources in an optimal manner. For example, the bandwidth available for the webserver is often limited, and throttling the data throughput is sometimes required. Speed is the most common reason to start performance-tuning, but it is not the only reason, nor is it the only important aspect of Apache. If the resulting webpage is incorrect, it is immaterial how fast it gets served to the client.

Apache 2.0

Most of this document applies to Apache 2.0 in more or less the same manner as to Apache 1.3. The biggest exception is the section describing MaxClients and the related options, as Apache 2.0 offers a variety of execution models that each have their own settings. Aside from that, the external modules described here are not all available for Apache 2.0.

Performance-tuning

To effectively tune any program or process, it is important to know where tuning would be effective. Speeding up the fastest aspect even more is unlikely to have a significant impact on the overall performance. Finding areas where performance-tuning would be effective can be tricky even with benchmark programs such as ApacheBench, because most such programs do not give more than an overview of performance. It often requires very platform- and site-specific information to determine the best ways to optimize.

The focus of this paper is therefor to give an overview of common ways to optimize Apache and how to find out where those ways could be beneficial. They have been divided in four sections, ranging more or less from trivial to intricate and delicate.

  • Tweaking the Apache Configuration
    Sacrificing little features for speed.
  • Reducing network load
    How to get Apache to generate less traffic.
  • Customizing Apache for better performance
    Re-fitting your Apache setup for your specific needs
  • Speeding up CGI scripts
    Using 3rd party modules to speed up CGI scripts.

Tweaking Apache Configuration

In general it can be said that features cost speed. The fewer features that are actually enabled, the more quickly Apache can handle requests. In some situations, however, it is hard to figure out whether you need a specific feature or not, or how hard it would be to do without it. The following section covers some optional modules and configuration directives that can positively and negatively affect speed. Most of these, and some more, can also be found in the Performance Notes section of the Apache manual.

mod_status and ExtendedStatus

The standard Apache module mod_status enables a configuration directive ExtendedStatus, which causes Apache to maintain extra information on the requests Apache is handling and the performance of it. While this information can be useful for benchmarking or locating bottlenecks, it also takes extra effort to gather it, and thus reduces performance.

ExtendedStatus is off by default, and can be switched on or off using the server-global ExtendedStatus directive.

Hostname Lookups

Apache has the ability to do a DNS lookup for each request that comes in, in order to log the hostname of the remote host rather than the ipaddress, and to pass it to any CGI script that gets executed. DNS lookups can be quite time-consuming, however, especially if the name-servers for the ipaddress fail to respond. For the logfiles, hostname lookups are better done by a separate logfile-parser. For CGI scripts, as far as they really need the resolved hostname, most programming languages have a way to resolve it themselves.

Apache also allows turning hostname lookups on or off selectively, by including the HostnameLookup directive in File or Directory statements. Note that there is no real performance benefit in making CGI scripts do the resolving themselves, except by reducing the number of lookups done.

Symlinks

In order to improve security, Apache has specific checks to avoid being fooled by UNIX symbolink links. If these precautions are not taken, it is possible to fool the Apache server to serve files it is not supposed to serve, such as files containing password-data for restricted directories. Denying Apache access to those files is often impossible because they are needed by the mod_auth modules, or by CGI scripts which execute with the same permissions as Apache. In absence of such sensitive data or malicious users, or when using mod_disallow_uid to deny access to those files, turning off symlink security can be considered.

Apache's symlink handling is handled by two mutually exclusive options, FollowSymlinks and SymlinksIfOwnerMatch, which can be included in any Options directive, except one contained in a Location directive. FollowSymlinks disables the symlink checks, while SymlinksIfOwnerMatch enables symlinks only if the owners of the source directory and the target file or directory match. SymlinksIfOwnerMatch considered if speed is not an issue, but security and the ability to use symlinks inside documentroots are, as SymlinksIfOwnerMatch still has to examine each path element.

The symlink checking requires an extra filesystem lookup (via the lstat() systemcall) for each path element in the location being opened, resulting in several such lookups per request. None of these lookups are cached by Apache. Filesystem lookups can be relatively slow, and when using a remote file storage such as an NFS server, can be quite taxing for the NFS server as well as the webserver. A busy webserver with several deep document trees and symlink-checking enabled can easily bring down a heavier NFS server by the number of lstat() calls and their network traffic. It is possible to enable symlink checks only for specific directories (and their subdirectories), disabling it for safe paths, but with deep directory trees this can still be a burden.

AllowOverride

The Apache directive AllowOverride is one of the most powerful and versatile directives in the Apache arsenal. It allows for the runtime reconfiguration of Apache for a specific directory (and all its subdirectories.) If AllowOverride is enabled, Apache checks for a specific file (configurable, but the default of .htaccess is practically never changed) in each directory that it visits, and parses it for configuration directives. This feature is most commonly used to limit access to directories (ask for a password), but the .htaccess file can contain almost all Apache directives.

Unfortunately, this level of flexibility comes at a price. In order to see the .htaccess files, Apache has to scan for it in every directory, resulting in the same number of filesystem lookups as the symlinks case previously discussed. It should be noted that checking for .htaccess and symlinks has to be done in two separate and different stat() systemcalls, so disabling only one of the two still reduces the number of lookups significantly.

AllowOverride can be set to multiple values. Only setting it to None will turn off the checking for .htaccess files altogether. Like the FollowSymlinks and SymlinksIfOwnerMatch directives, AllowOverride can be specified on a per-directory basis. Even if the VirtualHosts want or might want to use the .htaccess functionality, it is a good idea to turn off AllowOverride for directories that will never contain .htaccess files. The default Apache configuration does this for the system root directory, only enabling AllowOverride for the server's DocumentRoot.

mod_include

mod_include is the Apache module that parses Server-Side Includes files (generally .shtml files.) On some sites, mostly those based on old NCSA Webserver configuration files, the mod_include module gets invoked on every .htm(l) file, causing an extra pass over each such request. In general, this is not necessary, though a check to make sure no .htm(l) files contain SSI statements might be required to make sure.

MaxClients and Max/MinSpareServers

Apache has several statements to configure the number of clients being handled and the number of child-processes it forks off to deal with those requests. If the machine running the Apache installation is not intended for anything but running Apache, it is generally a good idea to make these numbers as high as possible, but not so high that the machine starts paging memory out to its swap space.

MaxClients

MaxClients limits the number of children Apache creates to handle requests, and because each child only accepts one connection at a time, the total number of concurrent connections. Setting this too low has a disastrous effect on performance. While all clients are busy handling connections, new connections will be put in the TCP queue and eventually timeout, while the machine itself will seem perfectly responsive and fast. It is generally a good idea to set MaxClients as high as the machine can handle in terms of memory. Setting it too high will cause the machine to swap needlessly, which effectively kills performance. If the machine can handle the number of processes in memory, but can't handle the sheer number of requests, it is often not useful to lower MaxClients. Instead, tuning Apache elsewhere, throttling one or more virtualhosts or simply sharing the load with more or bigger servers is the way to go.

MaxSpareServers and MinSpareServers

MaxSpareServers and MinSpareServers control how many spare (unused) child-processes Apache will keep alive while waiting for more requests to put them to use. Each child-process consumes resources, so having MaxSpareServers set too high can cause resource problems. On the other hand, if the number of unused servers drops below MinSpareServers, Apache will fork new child-processes (at a variable rate with a maximum of 32 forks per second) until MinSpareServers is satisfied. Forking a new child can be an relatively expensive operation, depending on the underlying operating system, and if a sudden burst of requests use up all the spare servers, the clients will be waiting for this. And new requests will pile up in the mean time.

The best values for these are highly system specific, and can change frequently even for specific sites. Fortunately it is usually not critical to get them exactly right. MinSpareServers should be a number high enough to satisfy sudden bursts of requests, to give Apache enough time to create new children. MaxSpareServers should be a number high enough to cover the normal fluctuation in numbers of requests, but not the daily fluctuations.

StartServers

StartServers controls the number of child-processes that Apache forks before starting to accept connections. If this number is lower than MinSpareServers, Apache will start forking off children while accepting connections, until the number of idle servers is at least MinSpareServers (but starts killing them off if the number exceeds MaxSpareServers.) It is a good idea to set StartServers to the minimum amount of servers you need active to start requests. When frequently restarting Apache during peak hours it might be prudent to raise this number to an average peak number, as killing off children while the server is not busy is less of a performance hit than creating children while busy.

Apache 2.0

Apache 2.0 has a more modular setup where the actual handling of connections is handled by Multi-Processing Modules (MPMs). The traditional pre-forking model of Apache 1.3 is available as an MPM, as is a multi-threaded variant. Which MPM is optimal for any particular system depends on a number of things, such as the efficiency of threads versus the efficiency of processes. For some platforms the choice is made simple by the available platform-specific MPMs, such as for Windows.

More performance tweaking

The Performance Notes of the Apache manual contains some more hints on performance-tuning, but most of those, especially the Serialized Accept section, are very low level and beyond the scope of this paper. See the Apache manual for more information.

Reducing network load

The following three modules can be used to reduce the network load generated by Apache. Of these, only mod_gzip will have any effect if the bandwidth bottleneck is outside of your control, like the user's modem connection.

mod_gzip

The mod_gzip module attempts to reduce bandwidth use by compressing data that is being sent out. If the browser claims to accept 'gzip' encoding, files can get compressed using the Lempel-Ziv coding (LZ77), the same algorithm used by the UNIX 'gzip' command. This compression comes at a cost of processing time on both the server and the client, however. The modules allows specifying which files are eligible for compression, so that files that are already (partially) compressed, and which would have little to gain by compression (like .gz files, .jpeg files, etc.) can be skipped.

The module is especially effective when using it to compress text-files (and thus HTML files) which are easily compressible. The mod_gzip module and the accompanying documentation can be found at http://www.remotecommunications.com/apache/mod_gzip/.

In Apache 2.0, mod_gzip's functionality is replaced by a new standard module, mod_deflate, which is documented in the standard documentation.

mod_bandwidth

Mod_bandwidth is a bandwidth throttling module, useful for keeping the traffic of a whole Apache installation or of specific VirtualHosts or directories in check. It allows for two rates, one for general data and one for files larger than a specified value, making it convenient for quenching file-downloads so the rest of the site is still responsive.

Throttling can also be done at the OS level, rather than the application level. For throttling entire Apache installations or IP-based virtualhosts this is often more efficient. However, throttling a name-based virtualhost or a directory within a virtualhost is not possible that way.

The throttling comes at a price of extra calculations on every packet send, and a local scratchboard to keep track of bandwidth usage. It is a good example of non-speed oriented optimizations. Mod_bandwidth can be found at http://www.cohprog.com/mod_bandwidth.html. Documentation is included in the C source file.

mod_proxy

Another method to reduce traffic for a specific server and increase the speed with which pages are served is by using a front proxy. The standard Apache module mod_proxy can serve as a front proxy. A front proxy keeps a cache of recently requested pages and returns the page from that cache if at all possible. Front proxies are only useful if the real storage of the data is slower than the cache of the proxy. For example, frequently requested data that resides on a remote NFS server or on a slow disk or CD can be significantly sped up by a front proxy.

Another common use of mod_proxy (with the help of mod_rewrite) is to split up requests to several servers, based on the URL, so that static content is taken from one server while auto-generated and server-intensive pages are taken from another.

Mod_proxy is useful for more than just playing front proxy, but it is not suited for every task. Since it was designed to proxy for other servers, not the server it is loaded into, it can be tricky to incorporate into existing setups. And since mod_proxy is a cache, the logfiles of the actual server no longer contains information of hits that were satisfied in the proxy. Furthermore, since all requests have to pass through the proxy server, it is still a bandwidth and speed bottleneck. Both mod_proxy and the documentation for it (which includes examples of configuring it as a front proxy) are part of the standard Apache distribution, though the module is not compiled in by default.

Customizing Apache for better performance

Site specific modules

While Apache is a great piece of software that is both very flexible and very efficient, it can't always be both at the same time. hard-coding site-specific information, thereby avoiding the sometimes complicated task of figuring it out at run-time, can in some situations provide a big performance boost. An example of this is the mod_userdir module. This module translates URLs in the form of http://host/~<user>/ into a user-specific path on the filesystem, allowing users to have a homepage with its documentroot inside their own UNIX homedirectory. Its typical use is simply like this:

		UserDir WWW
Designating the directory 'WWW' in a users homedirectory to be the documentroot for the above URL. But in order to find the homedirectory, mod_userdir has to query the system's password file. This can be a very slow operation, especially when that information is stored on a NIS or LDAP server. mod_userdir allows for this, by giving a template for the full path, with the username as wildcard:
		UserDir /usr/home/*/WWW
This avoids any lookups and simply does regular filesystem checks. But not all homedirectory structures fit in such a restricted template, and mod_userdir does not sport a full regular-expression rewriting engine such as mod_rewrite does. For instance, XS4ALL divides homedirectories into one-letter subdirectories, the first letter of the username. This is not uncommon when dealing with a large number of homedirectories, as filesystem limits and directory-access times quickly become important.

To still avoid slow NIS lookups, which XS4ALL also uses, mod_userdir was locally modified to simply hardcode a users homedirectory to /home/u/username. A solution using mod_rewrite, or extending mod_userdirs syntax would also have been possible, but would have cost more effort for no apparent gain. With the number of hits on user homepages XS4ALL gets, it should be noted that avoiding NIS lookups is important for the performance of the NIS servers as much as the performance of the website.

Mass Virtualhosting

One possible problem with Apache performance comes from large configuration files, especially many <Directory>, <Location> or <VirtualHost> blocks. Even though Apache uses hash-tables to optimize most of the lookups, these can still become large data-structures to wade through, and a lot of information to read in and parse at every restart. The actual impact is very system dependent, however.

The modules and directives in this section allow for more generic configuration. The main problem with these modules is that they require your server configuration to be very homogeneous.

Using regular expressions in Directives

The <Directory>, <Location> and <Files> directives can all take an extended regular expression instead of a regular directory, location or filename. While this takes some extra processing on each request, collapsing large lists of such statements into a single regexed statement can be well worth it. Reduced startup time and reduced process size can easily negate the added regexp match, especially when keeping the regular expression simple.

mod_vhost_alias

The mod_vhost_alias module is specifically intended to Apache to handle many VirtualHosts with just a few lines in the config file. Instead of specifying a <VirtualHost> block for each VirtualHost, each VirtualHosts' documentroot is calculated from the hostname passed in with the request, using a mod_rewrite-like rewrite-rule. Adding a new VirtualHost is then as simple as creating the directory for it. A common way to use this module is by mapping each request to /usr/local/WWW/www.domain.com/page where www.domain.com is taken from the 'Host:' header and page from the actual page requested.

The price paid is again that of loss of flexibility. VirtualHosts can no longer be configured with specific options (other than through .htaccess) and creating aliases for VirtualHosts has to be done using symlinks on the filesystem level (if symlinks are enabled in the Apache config.) The directory structure also has to be catered to the needs of this module, making it somewhat tricky to incorporate into existing installations.

mod_rewrite

A more generic approach to mass virtual hosting is mod_rewrite. Though this module has many, many uses, and is probably the most difficult to configure and understand modules in the standard Apache distribution, it can be an efficient replacement for situations where mod_vhost_alias is not versatile enough. The RewriteMap feature of mod_rewrite can use a mapping to calculate which directory to extract the files out of. A mapping can be a text-file of "<hostname> <WITESPACE> <Rewrite-to>" values, or a DBM hash containing <hostname> values as the keys and <Rewrite-to> values as the resulting values, or even an external program. (Though the latter is not likely to improve performance.)

As an incomplete example, here are some of the rewrite rules for doing mass virtualhosting using mod_rewrite:

	RewriteMap   vhost        txt:/usr/local/apache/conf/vhost.map
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1

Note: this example will not work properly, and is only intended to give an example of mod_rewrite's syntax. A complete example can be found in the URL Rewriting Guide which is part of the Apache manual.

Aside from the more extensive rewriting possibilities of mod_rewrite, it suffers the same problem as mod_vhost_alias: it is rigid in its configuration, disallowing per-VirtualHost customization except as part of rewrite rules. In addition, to activate a VirtualHost, the extra step of adding the server to the rewrite map has to be taken. And to define Virtualhost aliases, extra RewriteRules and a RewriteMap have to be added. Lastly, the syntax is clearly a downside, requiring very good inline documentation to be maintainable. Fortunately, the URL Rewriting Guide sets a good example in that, too.

Speeding up CGI scripts

CGI scripts are any program that gets executed on-demand by the webserver, and that uses the Common Gateway Interface to transfer information from and to the webserver and the browser that did the original request. Even though compiled C programs that use CGI are not technically scripts, they are often referred to as CGI scripts as well. A large portion of today's web programs are actually CGI scripts, though with the advent of PHP and other HTML-embedded server-side languages, those are getting more popular.

This section gives some hints on how to speed up the execution of CGI scripts. mod_fastcgi is a general FastCGI module, which uses FastCGI rather than normal CGI to connect to the CGI scripts. FastCGI uses some tricks to reduce the fork/exec overhead of a CGI script, but is not entirely backward compatible with normal CGI. mod_php and other such language-specific modules use language-specific information to speed up the execution process.

FastCGI

FastCGI is a slightly more complex alternative to normal CGI. With normal CGI, the webserver communicates with the CGI script through environment variables, and the client browser with the CGI script through its standard input. With FastCGI, each script acts as a daemon, being started once and handling multiple requests. Instead of environment variables, the server passes all information about the request through standard input, allowing FastCGI scripts to even be executed on different servers, over extra TCP connections.

The FastCGI interface allows for far more efficient use of resources, especially for oft-requested scripts, but might require a rewrite of the script in question to work properly. There are FastCGI API libraries for most popular languages, most of which allow a script to be used both though CGI and FastCGI without the need for modifications, but scripts that do not (yet) use these APIs do need to be modified, if not rewritten. FastCGI is best explained on its website, www.fastcgi.com, which also contains the Apache module and the API libraries for most languages.

mod_<language>

For several scripting languages (including Perl, Python, PHP, Tcl and Ruby) there are separate interpreter modules that give the language more control over Apache, as well as a performance boost. In general this is done by using specific knowledge about the language, and by keeping the language's Interpreter or Virtual Machine hanging around, passing it scripts as they get invoked. This avoids the execution overhead, and in some languages the compiling phase.

Each of these modules defines a Handler, to which specific file extensions and mime-types can be mapped, so that files of that type automatically get parsed by the right module. Because the interface to the scripts is far more like CGI than FastCGI, CGI scripts often need no or little modification to work properly.

The modules generally also allow embedding the language directly in HTML, using special tags to indicate the start and end of such embedded code. PHP started this trend by being specifically designed for the task. Though the resulting file looks like a HTML page, it should not be thought of as such: it is a script. The performance of the resulting script is often somewhat worse than a normal script that outputs HTML, because the HTML file has to undergo extra parsing to extract the HTML snippets.

The Perl module, mod_perl, can be found at: perl.apache.org.
For Python there are two competing modules, mod_snake and mod_python. mod_snake was originally written for Apache 2.0, has been ported to Apache 1.3 but is currently not being maintained. mod_python provides less functionality, but is also more lightweight because of it.
For Tcl there are actually several modules, each with their own special focus. They can all be found under tcl.apache.org.
PHP is a language that got popular mainly because it was easily embeddable in HTML. It is currently in its fourth incarnation and is still undergoing improvements and expansions. PHP can be found at www.php.net
Ruby is another OO scripting language that is growing in popularity, with its own language module. mod_ruby can be found at www.modruby.net.

Java

Though the Java support could have been listed in the mod_<language> section, it is currently a special case in Apache. A separate Apache project, Jakarta, covers all Apache/Java integrations, to provide an open-source, portable platform for JavaServlets. The author of this document is insufficiently educated in Java and Jakarta to say anything about it at all, let alone about its performance. For more information, see jakarta.apache.org

About this document

This document is intended as companion to the Performance-tuning Apache ApacheCon presentation, and is written and maintained by Thomas Wouters. The latest version can be downloaded from http://www.xs4all.nl/~thomas/apachecon/. The author can be reached at thomas@xs4all.net.


Posted by zdravko on November 13 2006 14:11:49 1248 Reads · Print
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Shoutbox
You must login to post a message.

godemo
15/11/2008 04:56
A demo for Simple Feedback ZDR would be nice

dot
29/07/2008 21:23
hey can anyone help me here with how to link Submit button to a thank you page

dolarat
10/03/2008 12:17
hey all

konv
21/02/2008 04:19
i may be in the wrong place but here goes ,i want to learn about shell/severs .as i am having problems staying connected to a irc chay room because of major lag from their saever any help would be app

Copyright © 2008 - www.webtoolbag.com