Apache 2.2 vs Apache 2.4

What improvements have been made in Apache 2.4, and should a person upgrade?

Once I select a web host, I will need to figure out what versions of software to go with.

It seems like most hosts are still on Apache 2.2, but I would like to use the latest version unless there is a reason to avoid it.

As far as I can tell, it would not impact my websites code.

I do have a .htaccess file, but the only it contains are lines of code like these…

RewriteEngine on

#Prevent Directory Listings
Options -Indexes

#Handle Access-Denied.
ErrorDocument 403 "/other/access-denied.php"

#Handle Page-Not-Found.
ErrorDocument 404 "/other/page-not-found.php"

#Rewrite user-friendly URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule account/profile/((.+)/)?(.+)?$ account/profile.php?user=$2&tab=$3 [L]

Apache is definitely not my strong point, and currently I am using it minimally to protect against things like directory listings and to allow me to offer easy to read URLs and then change them to a more standard format for PHP to handle.

Read the release notes?
http://httpd.apache.org/docs/trunk/new_features_2_4.html

Yes, I skimmed them last night, although since I barely know Apache, they were rather confusing.

That is why I am asking for suggestions here.

So, is there anything in the code above that might cause issues in Apache 2.4 (I don’t think so, but could be wrong.)

Also, are there any other gotchas that maybe I am missing?

Not that I can see. It looks like not a lot changed. There were some new features added, performance improved, but nothing really altered (a couple of things deprecated, but nothing that affected your .htaccess).

The only thing I recall reading about several months ago was that Apache changed how the “Apply All” and “Deny All” worked, or something like that.

I guess it is both good and bad that I don’t take more advantage of Apache. Good in that upgrading won’t break anything, but maybe a loss in that I am not using Apache to its fullest capabilities.

BTW, is Apache supposed to be markedly faster now, or about the same as v2.2?

In comparison to what? To 2.2, it will be slightly faster (as it uses less memory which will means they improved the processing and how long it holds onto its data).

lighttpd and nginx likely will still outperform apache.

Take this with a grain of salt, as I didn’t notice where they mentioned what versions of each web server they were testing, but this is some food for thought
http://wiki.dreamhost.com/Web_Server_Performance_Comparison

@cpradio,

Funny you should provide that link, because until yesterday I had never heard of nginx.

I saw a similar review on another website.

If I recall correctly, those blazing speeds are with static webpages. The other article - which I didn’t bookmark - mentioned that if you have a dynamic website, the differences between Apache and nginx are smaller.

Does anyone have any real life experience with this topic?

I always though that Apache was the premiere webserver and creamed everyone else. (Guess times have changed?!)

Not sure why that would be… As all Apache and nginx and lighttpd do is pass the PHP file to the PHP parser and then load up the result to the client. So the real test is how they deal with traffic and handling requests. If you have a slow loading PHP page, it will remain slow regardless of the web server until you correct the issues within that page (pragmatically).

If your PHP code takes 5 seconds to be parsed, it will take 5 seconds regardless of which web server calls the parser. It is out of the web server’s hands at that point.

I wouldn’t say it that way, I’d more so say, its stability and reliability has been proven over the years and continues to hold true. The competitors have simply come in to process things faster/quicker by using asynchronous processing and not having to deal with all of the modules, etc that Apache has bundled in.

Case in point, if you go to this one, you’ll quickly start to notice that on all of the graphs Apache 2.2 and 2.4 remained consistent in relation to the number of cores available for processing.

Apache is a very reliable web server. nginx in my opinion is also reliable (it has had enough time to prove itself as well). I don’t really know a lot about lighttpd or the various other contenders.

So if Apache is one of the slowest webservers, then why still use it?

It seems like nginx is anywhere from 5-10 times as fast - that is pretty significant!

If I had a web host install nginx instead of the standard Apache, would it screw up PHP, MySQL or any other standard packages that comes with your typical web hosting plan?

Probably because you are familiar with it, you have IT who can easily use it, or you may want to use several of the hundreds of different modules it has available to it.

It shouldn’t. Your .htaccess will have to be rewritten though, as nginx uses a different syntax.

@cpradio,

So, how important is the web server a person chooses to handling web traffic?

Currently I am shopping around for web hosts with the hopes of setting up a VPS for a client of mine. I have never done system admin/webmaster/web hosting before, so it new and scary to me.

I am very confused what size of VPS to get, and how things like the web server or version could affect performance of my client’s website.

One of the packages I looked at had 2GB of RAM, 40GB of Storage, and 500GB of Bandwidth per month, and came with Apache 2.2 although I think that could be changed.

For a website that is mainly content with a moderate amount of pictures, but no advertising or “eye candy” junk, how many concurrent users do you think such a VPS would handle?

20? 100? 500? 1,000? 5,000? 10,000?

And would something like Apache be the “bottleneck”?

I’m totally clueless on doing the math for this, and my client of course wants to know how much he has to spend, and how well things will perform.

When I have researched this topic online, there really aren’t any “guides” out there, and what I have seen varies from 10 users to thousands which is had to believe.

If I can stay with Apache that would be beneficial since it is more standard and since I don’t want to have to rewrite my .htaccess this late in the game. Then again, if switching web servers could allow up 5X as much traffic, then i would consider switching!

You may want to start out with a managed VPS, it costs a bit more per month, but they manage the VPS for you. So you are not in charge of the web server intricacies.

However, the one thing to take away from the earlier article I mentioned is that Apache uses quite a bit of memory. On a VPS you are charged by memory/CPU usage. You buy X amount and the only way to get more, is to buy it.

Personally, I’d start with Apache. It seems to be more “user friendly”, tons of resources/documentation, is reliable and stable. If you find yourself hitting that 2 GB ram limit fast and hard and can’t or don’t want to put up more money to get beyond that cap, then I’d strongly consider nginx or look at implementing a strong caching service, such as, Varnish to try and help lower your memory consumption.

2.4 would be better for memory usage than 2.2, so if given the choice, choose 2.4. Will you eventually bottleneck? Yes. All websites do. Then you get a second server and load balance them, or switch to nginx, or use Varnish. The solution is difficult to tell you at this point primarily because you can bottleneck for multiple reasons. The solution(s) depend on the reason your server is bottlenecked.

So right now, my advice is stick with Apache (try to use 2.4). Try to go with a managed VPS (if it fits your budget), let them worry about the integrity of the VPS, don’t let that be your responsibility. After you get through the launch and it is running smoothly (say for 6 months), look at going unmanaged to reduce cost but you better be ready for everything that pertains. You will be in charge of that VPS, the operating system, the web server, version of PHP, version of MySQL, security patches, etc.

As you reach your caps, look into why the cap was reached. Poor processing of data (can you write it to be more efficient so you don’t hit the CPU/RAM cap?), Apache can’t keep up with the traffic? Too much server processing going on (can you cache the data?)? etc.

1 Like

cpradio,

Thanks for the insight.

Per recommendations from DKLynn and Felgall, I am very interested in WebHostingBuzz. They offer semi-managed VPS for a decent price. (By semi-managed, I mean they cover critical stuff like maintaining the Op Sys and Apps and they do free patching.)

Can you take a best guess at how much traffic the VPS package I described might handle?

If it would only handle 20-50 concurrent users, then that obviously won’t work. However, if it is good for up to maybe 1,000 concurrent users, then I’d say that buys us enough time for my client to get his business off the ground and get some money coming in while I research more robust solutions.

If you look at the second URL I provided (maybe the third), it has the following graph

Since you are on a 1 CPU Core, you can clearly see that Apache will serve the same number of requests over 1, 500, 1000 concurrent connections and the number of requests can be approximated around ~8,000, so I don’t see that being a problem as a starting point.

Worst case, you upgrade to a 2 CPU Core system which gives you 10,000 to 12,000 requests at which point you are starting to max out Apache (depending how accurate that graph and test was) and you’d want to look at Load Balancing between two servers or using a Varnish cache server to load data from as well as Apache.

Hope that helps.

Edit:
You may want to look into implementing Varnish as soon as you go live. Regardless of where your traffic starts, Varnish will significantly help you out.

Yes I did see that earlier. But what I am still unsure of is what it would take to handle 1,000 or 5,000 or 8,000 concurrent users.

Is it just Apache? Is it mainly RAM? Is it mainly CPU? Something else? Or all of the above?

I always thought that RAM was the bottleneck, but looking at the graph above makes me think the web server is the bottleneck.

To be honest, I was under the impression that an average website that didn’t have lots of junk on it would be able to serve tens of thousands of users easily with a basic web hosting plan.

I mean in the scheme of things, most people wouldn’t brag that they had 10,000 visitors on their site, or would they?

With all of the people on the Internet, it just seems like until you get up to hundreds of thousands or millions of visitors it isn’t that big of a deal.

Then again, I really have no clue about this realm… :relaxed:

His tests were done with 4 GB of RAM and 1 CPU (for the graph I pasted). So all of the above. Apache creates worker processes, much like other web servers do, to perform its work. Those processes will be limited by the amount of Memory and CPUs you have available.

And they do, but you rarely have tens of thousands of users hitting your web page all at the exact same time (that is concurrent). Look at Facebook, who does have that problem (tens of thousands of users hitting their service at once). They have an entire data center of servers to handle the requests. Not just a single server.

Again, we are talking concurrent users? As I can serve 100,000 users content, but if I did it over the course of a month and had 3,333 of them a day, 138 of them an hour, I’d only have roughly 2 concurrent at a time (per minute). That’s hogwash to Apache.

So to be able to crunch these numbers you need to know the following:
1 user 1 visit, how many requests are made to apache to load the page? The page itself, any JavaScript files, CSS files, images, etc. Take all of those and add it up… let’s assume 30.

So 1 user, 1 visit = 30 requests to Apache.

5 users, 1 visit = 150 requests to Apache.

If Apache can say it can serve 8000 requests, how many concurrent users is that when each user will have 30 requests? 8000 / 30 = 266.66 users.

Now let’s say you move all of your images, JavaScript, and CSS to a CDN, so your server doesn’t process that. So 1 page is really 1 request (as everything else comes from the CDN) hosted by CloudFlare or MaxCDN, or whatever. Now you can support 8000 users.

Make sense?

1 Like

If you had to guess…

How many Visitors does SitePoint have in any given day?

And how many Concurrent Users does SitePoint typically have on it?

Wow! I had no clue that is how things worked! I thought 1 Person = 1 Visitor = 1 Apache Request.

So is that a lot of traffic or not?

What would be a real-world example of a website that averages 266.66 Concurrent Users during normal times?

What is CDN?

Does that have to do with this “Varnish” thing you mentioned?

Yes, this is very informative, although it is also overwhelming! (Clearly I have very little idea of how the Internet and the Hardware/Software that runs it work?!)

How can I get a better handle of how many “Apache requests” a given page on my client’s website is making?

How can I, in general, learn more about these things so i can start acting like a competent System Administrator/Webmaster?

If I had to guess. 300,000 to 400,000 page views a day.

Think of it this way. You have your HTML, your JavaScript, and your CSS for a single page right? They are 3 separate files right? So Apache must serve 3 files, hence 1 visit to a page = 3 requests to Apache. Add images, and the number goes up infinitely.

It is plenty. Remember that is 266 users at one given point in time. So let’s say it takes Apache 2 seconds to load your site. 266 users can view a completed page every 2 seconds.

Content Delivery Network. A lot of websites (including this forum) use them to host their images, stylesheets, and javascript. Since those items do not change often, we store them on a long-caching server so the user will typically download the file once and unless they clear their cache, they won’t have to download it again and thus lower the number of requests needed for visiting our page.

It is, but it isn’t. See http://devblog.factual.com/practical-guide-to-varnish (be sure to read through “A simple use case” to get an general idea).

CDNs unlike Varnish, do not and cannot be applied to dynamic content. The content must be static/versioned. For more info on CDNs, see http://www.sitepoint.com/7-reasons-to-use-a-cdn/

Go to http://gtmetrix.com/ and enter the URL, it will tell you the total number of requests next to the grades.

Go to the timeline and only count the files that come from your domain (so exclude any external requests your page makes). That is the number of requests Apache had to process for that single page visit.

Read a few books on Apache, Server Administration, etc. Experiment, break things, do a lot of tinkering :smile:

1 Like

@cpradio,

Thanks for all of the tips! (You just opened a whole can of worms for me!)

Looks like I have a lot to learn…

As far as my concerns about successfully hosting my client’s site, does it seem reasonable that getting a VPS with 1 CPU and 2GB of RAM using Apache 2.4 would be sufficient for the first few months?

Or do we have to get into multiple CPU’s and servers and CDN’s and Varnish in order to even go live?

Yes.

No, but I’d approach it in the following order:

  1. Get Site Live
  2. Get CDN and move static content to it (preferably all images, CSS and JavaScript)
  3. Look into Varnish for caching dynamic content
  4. Monitor sites responsiveness and traffic to determine if another server is needed to handle load (should be a long time before this is needed, unless you grow massively overnight)