Apache speed and reverse proxies

In our environment we use Apache everywhere. It's PHP integration has so far proven superiour. Now we're dealing with higher loads and we've hit some limitations.

One of the problems we had, is Apache's heaviness. Our apache2 worker processes eat up around 20 Megabytes of memory, and with 3 GB of memory will bring us up to a setting of around 150 MaxClients. Rasmus seems to think that's a pretty high setting, but based off the easy calculation (memory available for apache / size of an apache process) it works out for us.

Effectively this means we can serve approximately this much parallel request on this machine. It is therefore in our greatest benefit to get every response out as quickly as possible, increasing the amount of requests we can handle per second.

Going beyond this 150 number could cause Linux to start using swap. This is bad, because it will add latency to the response, which in turn will result connections staying open longer.

Since we're sending everything over the web, there is a standard latency. Information traveling to the other side of the globe will at least take 67ms because we're restricted to the speed of light. This doesn't even take non-direct routes nor other hardware latency into account. According to Till this all adds up to the time a single Apache process takes up before working on the next request.

The reverse proxy

There are a couple of webservers which seem to be optimized for serving lots of clients. Lighttpd got a lot of traction earlier, but the project seems to have slowed down a lot as the much anticipated 1.5 release has been under development for almost 2 years. nginx seems have taken it's place in terms of disruptiveness. These servers are much more lightweight, and are supposed to be faster in delivery of static files.

Much like Till, we've had issues hooking PHP directly into these servers. Till suggests the solution of actually placing nginx in front of Apache (on the same machine) as a reverse proxy. Nginx takes care of serving static files and proxies any PHP request to Apache. The concept is that Apache can push out the response as quickly as possible, and while Nginx is working on delivering it to the (slow) client Apache can take on other work.

The thing that bothers me with this setup, is that the need for 2 webserver products to achieve a single task. This implies that neither of them is adequate on it's own to do the job.

On the other hand, this type of setup is also what a lot of people seem to be doing by placing Squid in front of their webservers, although that tends to happen on separate hardware.

HTTP/1.1 100 Continue

All of a sudden we noticed a problem we saw earlier with Lighttpd (Bug #1017) was also an issue in nginx (couldn't find bug or bug tracker at all). Neither of them seems to support the Expect: 100-continue header. While no browser actually sends these headers, we have webservices running which are directly accessed by other types of HTTP clients. Losing support for this HTTP functionality would instantly break their applications, which is unacceptable.

So now we're actually looking at Squid for performing that task. Squid is powerful and well tested. We're going to start load testing this reasonably soon, and I have no problems reporting back here if people are interested in numbers. I'm wondering if there's other people who have tried a similar setup or if there's better ways to approach this problem.

Web mentions


  • guest

    nginx supports Expect: continue in 0.7.x branch also did you try php-fpm ?
  • daaku


    I started looking for Squid with Apache/PHP in the back info and got here - would be interesting to see what you see performance wise. Is this a highly dynamic site?
  • patrick


    Did you have a look at varnish yet ( Its a state of the art HTTP accelerator and much superior to squid. Its performance is just outstanding. We just did some tests on a eZ publish ( installation and while the basic (not optimized) apache setup served about 15 requests/second the varnish/apache setup was able to deliver 2500 requests (the network card was the bottleneck than). Of course configuration of varnish can be a bit tricky for more complex applications, but should be definitly worth having a look at it..
  • till


    Squid is a heavy weight compared to nginx. There's gotta be a reason though why so many people rely on it. ;-) E.g. wikipedia use a lot of Squid. I'm curious... a) Have you explored php-cgi (with nginx)? b) Your overall Squid performance. c) Can you detail when you use HTTP/1.1 100 Continue?
  • Evert


    Guest, Good to know they will support it in the future.. Also PHP-FPM looks interesting, but I don't like that there's not a lot of english docs. Not to say english is better or anything, but I can read that :) Daaku, Very much so.. We do a lot around social networking, so you can imagine we almost always need to make sure people see (at least their own) updates. Patrick, Varnish looks very cool! I love that it supports ESI as well, which could provide an upgrade path when we need to get on CDN's. Thanks very much for the link! Till, a) I have not yet, but this is a path I want to give a shot. b) I definitely will when I have numbers! c) I personally don't use it, but I noticed some of our clients use an HTTP client which uses this. Although I'm not 100% sure, I believe they build it using .NET.
  • Guest

    Evert, nginx 0.7 is stable enough, it is widely used in production already. And as I can see from changelogs, the Expect fix has been backported to 0.6.34. About php-fpm, well, the russian text mostly describes advantages of fastcgi and additional features; and the sample config are enough to start. And you are always welcome to ask questions in the highload-php-en google group.
  • Evert


    Guest, PHP-FPM definitely sparks my interest. One question.. Did you guys try or plan on getting the patches back into the main PHP source? Evert
  • Guest

    Evert, Anight, the developer of php-fpm, says that he does not want it to be merged until all the planned features are implemented and tested, so he intentionally releases it under an incompatible license (GPL) until he decides it's ready.
  • Tim Lieberman

    Tim Lieberman

    Are you running php inside apache via mod_php? If so, you might be able to do a lot better by moving to FastCGI, according to Anthony Ferrara: (
  • Evert


    Interesting Tim, I'll definitely check out that presentation. We do indeed use mod_php, because my experiences with PHP through FastCGI has been less than smooth. Guest, That's actually a bit scary! Maybe I'm completely missing the point, but I think there's a much much higher chance of acceptance to the PHP source if this stuff was done using many smaller fixes/patches vs. one big patch!
  • Stuart Herbert

    Stuart Herbert

    Assuming you're running Linux on the web servers, are you using the default Linux TCP stack parameters, or have you tuned them to perform better under heavy load?
  • Sebs


    We use exactly that combination of tools for a rack of 15 webservers serving millions of users and it works quite well. Both, Apache and Squid might not fullfill someones thrive for new technology. But they are heavily documented and rock solid. Its worth all the time you invest in it. You can run a squid proxy on localhost, which means one squid per webserver. No Extra hardware needed and surely worth the money. The beauty of it shines through when you tail squids access logs and see which requests do not even require the indian. ;)
  • Padraic Brady

    Padraic Brady

    "The concept is that Apache can push out the response as quickly as possible, and while Nginx is working on delivering it to the (slow) client Apache can take on other work. The thing that bothers me with this setup, is that the need for 2 webserver products to achieve a single task. This implies that neither of them is adequate on it's own to do the job." I think the main logic really is that nginx is just faster, especially in a situtation where applications are capable of caching themselves. At that point Squid becomes just another user of RAM that adds less of a benefit than using it in front of a non-caching application. And there is, without doubt, a scaling element. Squid is fantastic when scaling, but nginx can easily beat it at a smaller scale. It's a contest over resources, not functionality. Apache + Squid are heavyweights, Nginx + Application Caching are lightweights. Depending on your resources the winning strategy can go either way or simply tie. Someday though, someone will actually benchmark the two! At the moment it's largely a matter of opinion as to which works best in any one scenario. I definitely need to try out php-fpm!!! :)
  • Mmwrbauh


    Good work , <a href=" ">How To Make Money In School Fast</a> , 69528 , <a href=" elements/sculpture/578/texas-maps28.html ">Texas Maps</a> , 932808 , <a href=" ">Bank Disaster Recovery Plan</a> , 15979 , <a href=" ">Bampq</a> , =DDD , <a href=" ">0 Percent Interest Credit Card</a> , =O , <a href=" ">Girdlequeens</a> , 28649 , <a href=" ">F Secure Mobile Security Crack Serial Download</a> , 050526 , <a href=" "></a> , %-D , <a href="'s LINE6 FLEXTONE presets/924/adult-degrees-online26.html ">Adult Degrees Online</a> , 6440 , <a href=" ">Cumfiesta</a> , 8689 ,
  • Oaakkulf


    Lol lol lol , <a href=" ">Flashplayer</a> , 01189 , <a href=" ">Best Internet Bank Cd Interest Rate</a> , 27596 , <a href=" ">Norvasc</a> , asvm , <a href=" ">Phi</a> , 22260 , <a href=" ">Colorado Truck Accident Lawyers</a> , 874 , <a href=" ">Monkey Joes</a> , pxs , <a href=" ">Delaware Paid Surveys Online</a> , =) , <a href=" ">Celebrity Pictures</a> , jsy ,
  • Sskntrsi


    Good work , <a href=" ">Wireless Dsl</a> , fqa , <a href=" ">Arrest Records Public</a> , pdfpdw , <a href=" ">Case Tractors</a> , 931081 , <a href=" ">Septic Systems</a> , odxx , <a href=" ">A B C D E F G</a> , ncakm , <a href=" ">Lightscribe</a> , xreywd , <a href=" ">Agent Orange</a> , 296388 , <a href=" ">Watch Movies Links Net</a> , zef , <a href=" ">Ninja Cloak</a> , =PPP , <a href=" ">Duke Energy Bill Payment</a> , 4762 , <a href=" ">Carlos Bakery</a> , >:-OO ,
  • Hrtgvnhe


    Help me please , <a href=" ">Colorado Divorce Lawyers</a> , ufcz , <a href=" ">Indictment</a> , %P , <a href=" "></a> , =))) , <a href=" ">Informedconsent</a> , 3448 , <a href=" ">Earn Increase Money Online Site Traffic Web</a> , >:]]] , <a href=" ">Backup Restore Windows Xpexternal Disk</a> , :DD , <a href=" ">Fusker Galleries</a> , %-[ , <a href=" ">Pottery Barn Kids</a> , lkyybj ,
  • Ycmrddts


    Help me please , <a href=" ">Att Wireless</a> , 647 , <a href=" ">Can You Borrow Money From A Bank To Purchase Stock</a> , 121 , <a href=" ">Abc Tv</a> , gruam , <a href=" ">Ncis Full Episodes</a> , :-)) , <a href=" ">Southwest Airlines Reservations</a> , lrpj , <a href=" ">Asda Name Badges</a> , ymtxtf , <a href=" ">Repuestos Laptops Hp</a> , =-))) , <a href=" ">Celeb Movie Archive</a> , jfewo ,
  • Nlvjryzx


    Lol lol lol , <a href=" ">Bvi Catamaran Charter</a> , 301902 , <a href=" ">Free Guardianship Legal Forms</a> , 8) , <a href=" ">Downelink</a> , >:( , <a href=" ">Black Box</a> , qjtkyo , <a href=" ">Art Classes</a> , 089 , <a href=" ">Anthroposophy</a> , :-PP , <a href=" ">Air Flights June 1946 From London England To New York</a> , ovr , <a href=" ">Mt Stars</a> , wou , <a href=" ">500 Pay Day Loan Lenders</a> , naa ,
  • Hbzgxngp


    Lol lol lol , <a href=" ">Comcast Email</a> , 8-((( , <a href=" ">Virginia Department Of Education</a> , 71056 , <a href=" Us_files/_vti_cnf/261/full-moon108.html ">Full Moon</a> , zya , <a href=" ">Cd To Mp3 Converter</a> , %] , <a href=" ">Hair Extensions</a> , 8-[[ , <a href=" ">Car Rental Coupons Hertz</a> , 07767 , <a href=" ">Cnc Laser Cutting How To Program To Work</a> , 378 , <a href=" ">Videos Xxx</a> , >:[[[ ,
  • Injizkmu


    Help me please , <a href=" ">Revolving Line Of Credit With Debit Card</a> , %D , <a href=" ">Tallahassee Democrat</a> , =DDD , <a href=" ">Hamster X</a> , >:OO , <a href=" ">Quotes Life</a> , hqniv , <a href=" "></a> , 003 , <a href=" ">Crossbreed Holsters</a> , kkdwq , <a href=" ">Capital One2c Online Credit Card Payment</a> , 271720 , <a href=" ">Cheap Car Insurance Quotes For Uk Drivers Motor Home Bike</a> , 794090 ,
  • Sxmumcqr


    Help me please , <a href=" ">St John Ultimate Luxury Villa</a> , %-P , <a href=" ">Olympics 2010</a> , 057017 , <a href=" ">Best Credit Cards In Uk</a> , tqtdm , <a href=" ">Yahoo Mail</a> , uen , <a href=" "></a> , =) , <a href=" ">Air Conditioning Filters</a> , iuzr , <a href=" ">Apc Battery Backup</a> , fqnnde , <a href=" ">Albany New York Divorce Law</a> , %-PPP , <a href=" ">Avis Car Rental At Springfield Mo Airport</a> , 519 , <a href=" ">Nurit 2085</a> , avhevk , <a href=" ">Washington Dc Weather</a> , uwvpxy ,
  • Xghtzyoc


    Lol lol lol , <a href=" ">Australia Car Insurance Online</a> , >:-( , <a href=" ">Courtyard Marriott Hotels</a> , dymgj , <a href=" ">Kds Toplist Portal</a> , %OOO , <a href=" ">Bermuda Triangle</a> , %-)) , <a href=" ">7zip</a> , abug , <a href=" ">Mortgage How Much Can I Borrow</a> , kjfzav , <a href=" ">Whois Domain Search</a> , 0583 , <a href=" ">Canada Pension Plan</a> , rjap ,
  • Blnnxaqz


    Lol lol lol , <a href=" ">Hp 9740 17 Laptop</a> , :-DD , <a href=" ">Arc</a> , 6579 , <a href=" ">Wire Saw</a> , :-O , <a href=" ">Gateway Powerhouse Laptop Computer</a> , 995217 , <a href=" ">Farm Tractors</a> , tvrsgf , <a href=" ">Cherry Master</a> , qdo , <a href=" ">Health Education And Outreach Program</a> , 44888 , <a href=" ">Showtime Network</a> , 3691 , <a href=" ">Harris Teeter</a> , %-D , <a href=" ">Clean Hard Drive</a> , =-PPP ,
  • Fruhzbdd


    Lol lol lol , <a href=" ">Digitizer Ex Software</a> , jbi , <a href=" ">Short Term Housing</a> , kny , <a href=" ">Live Bands For Hire</a> , 828 , <a href=" ">100 Free Dating</a> , >:-OOO , <a href=" ">Bill Of Rights</a> , %-O , <a href=" ">Naked Pictures</a> , 873372 , <a href=" ">Camp St Regis East Hampton</a> , :-]]] , <a href=" ">256 Video Memory Dell Vostro</a> , 671868 , <a href=" ">Cc</a> , 226224 , <a href=" ">Sony Laptop Vgn Nr120e</a> , 67629 ,
  • Avpgvojj


    Help me please , <a href=" ">Bob Crane</a> , kzx , <a href=" ">Zac Brown Band</a> , ryyc , <a href=" ">Arkansas Awnings And Patio Covers</a> , ojg , <a href=" ">Citi Bank Mortgage Lowest Rate L</a> , svy , <a href=" ">Horoscope Symbols</a> , 231 , <a href=" ">American Fidelity Assurance</a> , 8913 , <a href=" ">Bad Credit Low Interest Debt Consolidation Loans</a> , 8-(( , <a href=" "></a> , avfpn , <a href=" ">Aldo</a> , :PP , <a href=" ">Preteez Video</a> , 530 ,
  • Skljvjlz


    Lol lol lol , <a href=" ">Nimh Batteries</a> , %-PP , <a href=" ">Amc Theatres</a> , sypo , <a href=" ">1800 Pet Meds</a> , =[[ , <a href=" ">Sean Cody</a> , wsdah , <a href=" ">Belt Conveyor Cover Chemical Resistance</a> , 13605 , <a href=" ">Chest Pain After Angioplasty With Stent</a> , 1548 , <a href=" ">Dhl Tracking</a> , 98930 , <a href=" ">Phun</a> , 68788 , <a href=" ">Candy Gift Baskets</a> , 20181 , <a href=" ">Cheap Hotels Outside Of Washington Dc</a> , >:D ,
  • Eoyyyqra


    Good work , <a href=" ">Harvard Business Review</a> , roy , <a href=" ">Voyeur Videos</a> , =]]] , <a href=" ">Youngvideomodels</a> , 2433 , <a href=" ">Adult Affiliate Card Phone Program</a> , ihohm , <a href=" ">Susan Miller</a> , rrxjdt , <a href=" ">Dell Inspiron 1150 Inverter Replacement</a> , sjux , <a href=" ">Anti Spam</a> , %-DD , <a href=" ">Car Accident Mustang New Hampshire</a> , mve , <a href=" ">Bigboobs</a> , >:-PP ,
  • Yikavzmy


    Nice work, thanks , <a href=" ">Mouse Pads</a> , =PPP , <a href=" ">Strategies For Teaching Esl Student</a> , >:-[[[ , <a href=" ">Crazy Horse</a> , 160632 , <a href=" ">Sunshine Savings Bank</a> , >:(( , <a href=" ">Winchester Firearms</a> , uwu , <a href=" ">Sony Laptop Accessories</a> , 8-P , <a href=" ">Chicago Tribune Online</a> , 2946 , <a href=" ">Florida Vacations</a> , djgh , <a href=" ">Fishing Boat</a> , :-]]] , <a href=" ">Us Presidents</a> , 278 , <a href=" ">Reine Elizabeth Hotel Onion Soup Au Gratin Recipe Montreal</a> , 563229 ,
  • Qwjfnrds


    Lol lol lol , <a href=" ">Community Financial Credit Union</a> , :DDD , <a href=" ">Erotic Beauties</a> , =-OOO , <a href=" ">Motorcycles For Cheap</a> , ghmj , <a href=" ">Spy Camera</a> , oyaarr , <a href=" ">Proflower Coupon</a> , ryyzt , <a href="'s LINE6 FLEXTONE presets/924/oklahoma-lottery198.html ">Oklahoma Lottery</a> , ndxg , <a href=" ">Hp Laptop Shuts Down</a> , 81101 , <a href=" ">Enfamil</a> , 07729 ,
  • Dewtgekg


    Lol lol lol , <a href=" ">Penthouse Forum</a> , 10697 , <a href=" ">Consolidated Credit Counseling Services Inc Non Profit Debt</a> , 07354 , <a href=" ">Mind Control Stories</a> , zzbfr , <a href=" ">Clinton Teleprompter</a> , %-) , <a href=" ">King Magazine</a> , doq , <a href=" ">Best Encryption Software</a> , 0918 , <a href=" ">Bifocal Contact Lenses</a> , >:[[[ , <a href=" ">Wireless Internet Providers</a> , =-[[ , <a href=" ">Amanda Holden</a> , 3607 , <a href=" ">Back Hair Removal</a> , ihi ,
  • Fritxupn


    Lol lol lol , <a href=" 2004_files/_vti_cnf/858/vacation-rentals-by-owner207.html ">Vacation Rentals By Owner</a> , 983 , <a href=" ">Kelly Brook</a> , ijcnfo , <a href=" ">Academic Clipart</a> , 8-DD , <a href=" ">Two Way Radios</a> , qmu , <a href=" ">Tax Return</a> , 6724 , <a href=" ">Pay Check Advance</a> , %] , <a href=" ">Lexmark Ink</a> , kvt , <a href=" ">Government Websites For Small Business Loans</a> , vquq , <a href=" ">1920 S Storefront Pictures</a> , tmeiov , <a href=" ">Addiction To Alcohol And Drugs</a> , :((( , <a href=" "></a> , 115759 ,
  • Cetglnin


    Nice work, thanks , <a href=" ">Gerber 400 Bone Handel Knife</a> , 8(( , <a href=" ">Scoliosis</a> , led , <a href=" ">Area Attorney Debtors Houston</a> , >:[ , <a href=" ">Sony Vgn Ar870 Computers</a> , 182 , <a href=" ">Monorail Lights</a> , tiy , <a href=" ">Her First</a> , 8-((( , <a href=" ">Bank Savings Interest Rates</a> , 425857 , <a href=" "></a> , saa , <a href=" ">Arizona Dui Lawyer</a> , %OO , <a href=" "></a> , vjzpeb , <a href=" ">Green Flag Route Planner</a> , 45576 ,
  • Sleacvds


    Help me please , <a href=" ">Health And Safety Quiz</a> , 832 , <a href=" ">The Great Depression</a> , >:((( , <a href=" ">Beaverton Oregon Used Lap Top Computer Store</a> , adb , <a href=" ">Narcissism</a> , qfpl , <a href=" ">Alberta Web Site Promotion</a> , acwi , <a href=" ">Dog Allergies</a> , 5426 , <a href=" ">Disney Land Paris Hotels</a> , :PPP , <a href=" ">Wardrobe Malfunction</a> , 16375 , <a href=" ">Fleshlite</a> , utsaoj ,
  • Sdqjewiu


    Good work , <a href=" ">Dennys</a> , :((( , <a href=" ">Cold Calling</a> , xeshpc , <a href=" ">Kindgirls Videos</a> , :[ , <a href=" ">2 Side Ink Jet Printers</a> , 6696 , <a href=" ">Tittypalace</a> , qmceii , <a href=" "></a> , =-[[ , <a href=" elements/sculpture/578/free-texas-holdem-online104.html ">Free Texas Holdem Online</a> , 096 , <a href=" ">Corporal Punishment</a> , kksolf , <a href=" ">Aspen</a> , 403975 ,
  • Kqvnbxbw


    Good work , <a href=" ">Hell</a> , pxrd , <a href=" ">Adjustable Rate Mortgages Vs Fixed Rate</a> , dhbt , <a href=" "></a> , 3589 , <a href=" ">Kid Laptops At Best Buy</a> , >:DDD , <a href=" ">Airport Car Rentals</a> , 8PP , <a href=" ">Tiffany Teen</a> , =) , <a href=" ">Preferred411</a> , =OOO , <a href=" ">Lmc</a> , nsi ,
  • Mxmgksvx


    Nice work, thanks , <a href=" ">Glamour Models Gallery</a> , sskhq , <a href=" ">Red Heart Yarn</a> , 8PP , <a href=" ">Academy</a> , %-[ , <a href=" ">Company Health Insurance Nationwide</a> , 2959 , <a href=" ">Mapquest Com</a> , >:-DD , <a href=" ">Weber Carbs Specs</a> , hqtno , <a href=" ">Crossword Puzzle Answer</a> , amlg , <a href=" ">Casting Couch Teens</a> , 877317 , <a href=" ">Digital Tv Without Satellite Dish With Bell</a> , vbyg , <a href=" ">Guaranteed Boat Loans</a> , xhtnwj ,