1

I am writing a web application, that should work with 1000 requests/second using Apache and MySQL. On my server I have Ubuntu installed. Can my application be faster if I install FreeBSD instead of Ubuntu?

Thanks.

1
  • 3
    in this case doenst' matter the OS but the webserver.. just don't use apache ;)
    – dynamic
    Nov 11, 2011 at 7:50

5 Answers 5

3

The difference between various *nix distros in speed is minimal. I would suggest you use nginx instead of Apache. That might really save your day :)

1
  • so true, nginx is way better at handling requests
    – poelinca
    Nov 11, 2011 at 7:55
3

When optimizing for performance, the selection of OS or Linux flavour matters the least.

  • On the hardware side, your kind of workload probably is happy if the server has plenty of RAM, say 8 or 16 GB. Of course the network connection should be fast, too.

  • First cover your back by making sure you have at least semi-sane settings for your Apache, PHP and MySQL. What are those, that's hard to tell by your two and a half line long question, considering there are books written about this topic. Actually, a separate book for each of the pieces of software above. Also consider replacing Apache with lighttpd or nginx unless you have some specific reason for Apache.

  • Then make sure your application doesn't have typical deadly sins, such as lack of caching, non-optimal or unnecessary SQL queries, fetching some resource from 3rd party server each page load, rendering some thumbnails from an original picture over and over again each page load, lack of SQL indexes, and so on.

  • When you are confident you have everything set up right, benchmark your server with Apache Benchmark, JMeter, Siege or plethora of other available tools. See if your server can handle the load. If not, go back to drawing board and figure out why.

  • Finally, when it comes to OS, it's not about what the OS is (at least when pondering between *BSD/Linux), but how it's tuned. Carefully choose the file system for your use; if you have lots and lots of small files, ext4 might not be the best choice in Linux, for example. On the other hand, the default kernel settings in typical distributions are fine for most workloads, but in more exotic environments things like I/O elevator, shared memory settings, or network parameters might have to be tuned. If you really need to enter this stage, congratulate yourself about a popular service and/or start thinking about getting more servers.

0

As far as your OS is based on Linux/Unix, then no problem.just OS should be TUNED properly and very carefully. the real thing is the performance tuning of Apache and MySQL. and you will surely require a load balancer to entertain 1000 requests/sec. or on the other hand, you can use a very heavy hardware with huge memory and CPU to accommodate everything on same machine. the things you should be concerned is - Careful balancing of Load - Performance tuning of Apache - performance tuning of MySQL (and as well separation of MySQL from Apache server)

4
  • I've got a server with 2G ram and two old crappy intel processors and I can crank 4000 rps out of it prior to any tuning. It's not that hard to get 1000 rps. Your bandwidth is going to be much bigger factor. Tuning apache would be a waste of time at this scale.
    – regality
    Nov 11, 2011 at 8:06
  • regality: Though with poorly written PHP scripts the performance WILL come down a lot. The worst ever PHP application I've seen got 7.5 http requests / sec according to Apache Benchmark. The hardware? Three servers, each with 2 x quad-core Xeons and 16 GB RAM. Luckily after complaining to developer we got the performance much, much, higher. Nov 11, 2011 at 8:09
  • @regality: may be you are serving a static HTML page :) but this is what the questioner wants. he need to serve dynamic content, for which 1000rps is HUGE thing.
    – Farhan
    Nov 11, 2011 at 8:13
  • @Frank, no, that benchmark is from a php script. Although it does have APC on and that benchmark doesn't include db access. The more important part that I didn't include is that over the LAN it gets around 400 RPS and from the outside world I'm really lucky to see 50 RPS. I was just making the point that you should prioritize bandwidth long long before tuning the OS and apache.
    – regality
    Nov 11, 2011 at 8:22
0

First off, BSD is not linux, but that's ok. BSD distros are typically faster than linux, but not enough for you to stress about it. But the fact of the matter is that your operating system is a very small factor in throughput (crappy OSs excepted).

Operating system, web server, database flavor, and programming language will have an insignificant impact on throughput in comparison to hardware. The only notable factor will be the guts in your server. Buy more ram, more cores and faster processors. That will speed things up.

But beyond that, if you are buying your own server, it is probably on your home connection. If you put this on a standard dsl line it is unlikely you could pump out more than 100 RPS. Just be a peach and buy web hosting somewhere that has fast connection to the interblag.

1
  • While your comment is true at face value, you take BSD and Ubuntu with the exact same ports/packages installed and true enough they'll run pretty damn similar. What makes BSD 'faster' out of the box is what it actually comes installed with, which is basically nothing, at least relative to Ubuntu. FreeBSD is also not for the feint at heart, if you are not an experienced admin then you shouldn't be even contemplating BSD on a production server until you have a solid amount of experience with it. If you think the learning curve is steep with linux it's that again with BSD. Jul 23, 2012 at 15:41
0

You could also go with ArchLinux, which is about as bare-bones as you can possibly get in a Linux distro.

As other people have already answered, there is typically not really any appreciable difference in speed between distributions; what matters is your configuration and the amount of processes running. That said, Arch is a good choice because you are in control of absolutely everything; you can be sure nothing else will slow down your server without your knowledge.

Besides the distribution, you need to analyze your application flow. Apache has a big footprint and can't serve as many simultaneous connections as some of its single-threaded peers (e.g., nginx, lighttpd), but it is the only good choice for a number of apps. If your pages are well-cached, you're using bytecode optimization, and your query time is low, there's no reason why it couldn't handle 1000 concurrent connections.

But if you're doing any kind of non-trivial processing, you will need to either start thinking about more efficient web servers, or clustering 2 or more Apache servers together in a load-balanced setup.

Not the answer you're looking for? Browse other questions tagged .